diff options
Diffstat (limited to 'challenge-320/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-320/eric-cheung/python/ch-2.py | 12 |
1 files changed, 12 insertions, 0 deletions
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))
|
