diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-02-27 12:10:46 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-02-27 12:10:46 +0000 |
| commit | b96b84242ffb5863a5762c6bc971ba26231602e8 (patch) | |
| tree | 4a30ae56685db8f3b3612b129283be3ad96f1cea /challenge-258/eric-cheung/python | |
| parent | 8e15400bef303b962a68489bc096e881d4823c79 (diff) | |
| download | perlweeklychallenge-club-b96b84242ffb5863a5762c6bc971ba26231602e8.tar.gz perlweeklychallenge-club-b96b84242ffb5863a5762c6bc971ba26231602e8.tar.bz2 perlweeklychallenge-club-b96b84242ffb5863a5762c6bc971ba26231602e8.zip | |
- Added solutions by Packy Anderson.
- Added solutions by PokGoPun.
- Added solutions by Niels van Dijke.
- Added solutions by E. Choroba.
- Added solutions by Luca Ferrari.
- Added solutions by Peter Campbell Smith.
- Added solutions by David Ferrone.
- Added solutions by Peter Meszaros.
- Added solutions by Dave Jacoby.
- Added solutions by W. Luis Mochan.
- Added solutions by Thomas Kohler.
- Added solutions by Ryan Thompson.
- Added solutions by Roger Bell_West.
- Added solutions by Matthew Neleigh.
- Added solutions by Mariano Spadaccini.
Diffstat (limited to 'challenge-258/eric-cheung/python')
| -rwxr-xr-x | challenge-258/eric-cheung/python/ch-1.py | 7 | ||||
| -rwxr-xr-x | challenge-258/eric-cheung/python/ch-2.py | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-258/eric-cheung/python/ch-1.py b/challenge-258/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..ece02350ec --- /dev/null +++ b/challenge-258/eric-cheung/python/ch-1.py @@ -0,0 +1,7 @@ +
+## arrInt = [10, 1, 111, 24, 1000] ## Example 1
+## arrInt = [111, 1, 11111] ## Example 2
+arrInt = [2, 8, 1024, 256] ## Example 3
+
+arrOutput = [elemLoop for elemLoop in arrInt if len(str(elemLoop)) % 2 == 0]
+print (len(arrOutput))
diff --git a/challenge-258/eric-cheung/python/ch-2.py b/challenge-258/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a6088a474b --- /dev/null +++ b/challenge-258/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ +
+## Example 1
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 1
+
+## Example 2
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 2
+
+## Example 3
+arrInt = [2, 5, 9, 11, 3]
+nInput = 0
+
+arrOutput = [elemLoop for nIndx, elemLoop in enumerate(arrInt) if bin(nIndx)[2:].count("1") == nInput]
+print (sum(arrOutput))
|
