From 7d67833e2e7de682d2d418145812d575218e0fa9 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Tue, 6 May 2025 15:45:31 +0100 Subject: - Added solutions by Eric Cheung. - Added solutions by Ulrich Rieke. - Added solutions by David Ferrone. - Added solutions by E. Choroba. - Added solutions by Mark Anderson. - Added solutions by Jaldhar H. Vyas. - Added solutions by Ali Moradi. - Added solutions by Feng Chang. - Added solutions by Vinod Kumar K. - Added solutions by Peter Campbell Smith. - Added solutions by Ali Moradi. - Added solutions by Feng Chang. - Added solutions by Conor Hoekstra. - Added solutions by Bob Lied. - Added solutions by Athanasius. - Added solutions by W. Luis Mochan. - Added solutions by Andrew Shitov. - Added solutions by PokGoPun. - Added solutions by Roger Bell_West. --- challenge-320/eric-cheung/python/ch-2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 challenge-320/eric-cheung/python/ch-2.py (limited to 'challenge-320/eric-cheung/python/ch-2.py') 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)) -- cgit