From b91a4623cd4c2b51f779f59b53310a0bd745f03f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 18 Mar 2024 17:15:14 +0000 Subject: - Added solutions by Eric Cheung. - Added solutions by Ulrich Rieke. - Added solutions by Andrew Shitov. - Added solutions by Peter Meszaros. - Added solutions by Feng Chang. - Added solutions by Mark Anderson. - Added solutions by Peter Campbell Smith. - Added solutions by E. Choroba. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. --- challenge-261/eric-cheung/python/ch-1.py | 13 +++++++++++++ challenge-261/eric-cheung/python/ch-2.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 challenge-261/eric-cheung/python/ch-1.py create mode 100755 challenge-261/eric-cheung/python/ch-2.py (limited to 'challenge-261/eric-cheung/python') diff --git a/challenge-261/eric-cheung/python/ch-1.py b/challenge-261/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..348279526f --- /dev/null +++ b/challenge-261/eric-cheung/python/ch-1.py @@ -0,0 +1,13 @@ + +## arrInt = [1, 2, 3, 45] ## Example 1 +## arrInt = [1, 12, 3] ## Example 2 +## arrInt = [1, 2, 3, 4] ## Example 3 +arrInt = [236, 416, 336, 350] ## Example 4 + +arrSplit = [] +for nLoop in arrInt: + arrSplit = arrSplit + [int(elem) for elem in str(nLoop)] + +## print (sum(arrInt)) +## print (sum(arrSplit)) +print (abs(sum(arrInt) - sum(arrSplit))) diff --git a/challenge-261/eric-cheung/python/ch-2.py b/challenge-261/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a275000b69 --- /dev/null +++ b/challenge-261/eric-cheung/python/ch-2.py @@ -0,0 +1,18 @@ + +## Example 1 +## arrInt = [5, 3, 6, 1, 12] +## nStart = 3 + +## Example 2 +## arrInt = [1, 2, 4, 3] +## nStart = 1 + +## Example 3 +arrInt = [5, 6, 7] +nStart = 2 + +nFinal = nStart +while nFinal in arrInt: + nFinal = nFinal * 2 + +print (nFinal) -- cgit