You are viewing a single comment's thread. Return to all comments →
Iper-pythonic
def stones(n, a, b): return sorted([a*x+b*(n-x-1) for x in range(0,n,bool(a-b) or n)])
Or simple
def stones(n, a, b): if abs(a-b) == 0: return [a*(n-1)] limits = sorted([a*(n-1), b*(n-1)]) return list(range(limits[0], limits[1], abs(a-b))) + [limits[1]]
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
Iper-pythonic
Or simple