Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
next(filter(balance, indexes), -1) solution in Clear category for Can Balance by Phil15
torque = lambda L: sum(dist * weight for dist, weight in enumerate(L, 1))
def can_balance(weights):
balance = lambda i: torque(reversed(weights[:i])) == torque(weights[i+1:])
return next(filter(balance, range(len(weights))), -1)
Dec. 12, 2018