aboutsummaryrefslogtreecommitdiff
path: root/challenge-225/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-225/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-225/eric-cheung/python/ch-2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-225/eric-cheung/python/ch-2.py b/challenge-225/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..64e98389f4
--- /dev/null
+++ b/challenge-225/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+## arrInt = [10, 4, 8, 3] ## Example 1
+## arrInt = [1] ## Example 2
+arrInt = [1, 2, 3, 4, 5] ## Example 3
+
+arrLeft = [0]
+arrRight = [0]
+
+for nIndx in range(len(arrInt) - 1):
+ arrLeft.append(arrLeft[-1] + arrInt[nIndx])
+ arrRight.append(arrRight[-1] + arrInt[len(arrInt) - nIndx - 1])
+
+arrRight.reverse()
+
+arrLeftRightSumDiff = [abs(arrLeft[nIndx] - arrRight[nIndx]) for nIndx in range(len(arrLeft))]
+
+## print (arrLeft)
+## print (arrRight)
+print (arrLeftRightSumDiff)