We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# Project Euler #240: Top Dice

# Project Euler #240: Top Dice

+ 1 comment **can anyone explain me the question**

+ 1 comment I tried a recursion logic .I get the 1111 and 3 other test cases right. All others are incorrect.

For values a = [15, 10, 8, 50]

I get 14178352532007. Can someone help validate if this is correct/high/low when compared to actual answer

+ 0 comments I don't understand. The example is working fine, but all of the other tests fails when I submit. What am I missing?

+ 0 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):

`l.append(i+1)`

for i in product(l, repeat= n1):

`if (sum(sorted(i, reverse= True) [:n3]) == n4): c+=1`

print (c)

+ 0 comments Is it guranteed to be resolved in slow Python?

See code below

string = input() n, d, m, s = tuple(map(int, string.split())) x = [l for l in range(1,d+1)] m = m * (-1) - 1 z = [p for p in itertools.product(x, repeat=n) if sum(sorted(p)[:m:-1]) == s] print(len(z) % (10**9+7))

Load more conversations

Sort 15 Discussions, By:

Please Login in order to post a comment