You are viewing a single comment's thread. Return to all comments →
from itertools import product
n1, n2, n3, n4 = map(int,input().split())
l=[]
c=0
for i in range (n2):
l.append(i+1)
for i in product(l, repeat= n1):
if (sum(sorted(i, reverse= True) [:n3]) == n4): c+=1
print (c)
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #240: Top Dice
You are viewing a single comment's thread. Return to all comments →
My program is giving correct output but the run time gets exceeded, please help in optimizing the code :)
from itertools import product
n1, n2, n3, n4 = map(int,input().split())
l=[]
c=0
for i in range (n2):
for i in product(l, repeat= n1):
print (c)