aboutsummaryrefslogtreecommitdiff
path: root/challenge-320/eric-cheung/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-320/eric-cheung/python')
-rwxr-xr-xchallenge-320/eric-cheung/python/ch-1.py9
-rwxr-xr-xchallenge-320/eric-cheung/python/ch-2.py12
2 files changed, 21 insertions, 0 deletions
diff --git a/challenge-320/eric-cheung/python/ch-1.py b/challenge-320/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..57f640454f
--- /dev/null
+++ b/challenge-320/eric-cheung/python/ch-1.py
@@ -0,0 +1,9 @@
+
+## arrInts = [-3, -2, -1, 1, 2, 3] ## Example 1
+## arrInts = [-2, -1, 0, 0, 1] ## Example 2
+arrInts = [1, 2, 3, 4] ## Example 3
+
+nPosCount = len([nLoop for nLoop in arrInts if nLoop > 0])
+nNegCount = len([nLoop for nLoop in arrInts if nLoop < 0])
+
+print (max(nPosCount, nNegCount))
diff --git a/challenge-320/eric-cheung/python/ch-2.py b/challenge-320/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..5e2c3d812c
--- /dev/null
+++ b/challenge-320/eric-cheung/python/ch-2.py
@@ -0,0 +1,12 @@
+
+## arrInts = [1, 23, 4, 5] ## Example 1
+## arrInts = [1, 2, 3, 4, 5] ## Example 2
+arrInts = [1, 2, 34] ## Example 3
+
+nElemSum = sum(arrInts)
+nDigitSum = sum([sum([int(charLoop) for charLoop in list(str(nLoop))]) for nLoop in arrInts])
+
+## print (nElemSum)
+## print (nDigitSum)
+
+print (abs(nElemSum - nDigitSum))