21 September 2026 · Advanced track
Relay Balance Split
Split a relay's readings where the two side totals are closest.
A relay records a sequence of energy readings. Choose a split between two neighbouring readings so that at least one reading stays on each side. Add the readings on the left of the split and the readings on the right. Compare the two totals by their absolute difference. Return the split position with the smallest difference. A split position is the number of readings on its left, so the first possible split is 1. If several splits have the same smallest difference, return the earliest split position.
Constraints
readings contains between 2 and 100000 whole numbers.Every reading is between -100000 and 100000.
Function signature
def relay_balance_split(readings):