Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Can Balance by twilyght
from typing import Iterable
def can_balance(weights: Iterable) -> int:
for i in range(0, len(weights)):
torques = [(j - i) * w for j, w in enumerate(weights)]
if sum(torques[:i]) + sum(torques[i+1:]) == 0:
return i
return -1
June 4, 2020
Comments: