You are viewing a single comment's thread. Return to all comments →
looking at the examples one can find a simple pattern: no need for all permutations, just the possible sums of a and b. sum=a*x +b*y where x+y=n-1
def stones(n, a, b): results=set([a*i+b*(n-i-1) for i in range(n)]) return sorted(list(results))
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
looking at the examples one can find a simple pattern: no need for all permutations, just the possible sums of a and b. sum=a*x +b*y where x+y=n-1