From 74b80bd2a65cf44846daef9b2ad157a5d3d43617 Mon Sep 17 00:00:00 2001 From: youngmoney87 Date: Thu, 6 Apr 2017 17:51:56 -0600 Subject: [PATCH] Update EquilibriumIndex.py --- EquilibriumIndex.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/EquilibriumIndex.py b/EquilibriumIndex.py index b691b90..54540df 100644 --- a/EquilibriumIndex.py +++ b/EquilibriumIndex.py @@ -1,2 +1,11 @@ def eqindex(data): - #do code here + indices = [] + left, right = 0, sum(data) # initiate left and right sums + for index, current in enumerate(data): + right -= current # keep running total of right sum + if right == left: + indices.append(index) + left += current # keep running total of left sum + if not indices: + return None + return indices