diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-03-18 17:15:14 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-03-18 17:15:14 +0000 |
| commit | b91a4623cd4c2b51f779f59b53310a0bd745f03f (patch) | |
| tree | 2c384443a6fd55d2c7e9d09429ba5aefa253e849 /challenge-261/eric-cheung/python | |
| parent | 9f566417b406a3632edf6e95be57a9ae4c334703 (diff) | |
| download | perlweeklychallenge-club-b91a4623cd4c2b51f779f59b53310a0bd745f03f.tar.gz perlweeklychallenge-club-b91a4623cd4c2b51f779f59b53310a0bd745f03f.tar.bz2 perlweeklychallenge-club-b91a4623cd4c2b51f779f59b53310a0bd745f03f.zip | |
- 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.
Diffstat (limited to 'challenge-261/eric-cheung/python')
| -rwxr-xr-x | challenge-261/eric-cheung/python/ch-1.py | 13 | ||||
| -rwxr-xr-x | challenge-261/eric-cheung/python/ch-2.py | 18 |
2 files changed, 31 insertions, 0 deletions
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)
|
