You are viewing a single comment's thread. Return to all comments →
python
def stones(n, a, b): # a_count + b_count = n-1 answer = [] if a>b: a_count = 0 b_count = n-1 while a_count<= n-1: tmp = a_count*a+b_count*b if tmp not in answer: answer.append(tmp) a_count+=1 b_count-=1 else: a_count = n-1 b_count = 0 while a_count>= 0: tmp = a_count*a+b_count*b if tmp not in answer: answer.append(tmp) a_count-=1 b_count+=1 return answer
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 →
python