Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Can Balance by Rcp8jzd
from typing import Iterable
def can_balance(weights: Iterable) -> int:
weighted_sum = sum(index * value for index, value in enumerate(weights))
balance, remainder = divmod(weighted_sum, sum(weights))
return balance if not remainder else -1
April 9, 2020
Comments: