aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-03-26 12:54:56 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-03-26 12:59:59 +0000
commit8842119bb35f93e61b50e502df390d97903a6e9e (patch)
tree6298201180e389d24df3e018db5400ad2f43642d /challenge-262/eric-cheung/python
parent38676de2ac85384680efb69898afd3175aba5702 (diff)
downloadperlweeklychallenge-club-8842119bb35f93e61b50e502df390d97903a6e9e.tar.gz
perlweeklychallenge-club-8842119bb35f93e61b50e502df390d97903a6e9e.tar.bz2
perlweeklychallenge-club-8842119bb35f93e61b50e502df390d97903a6e9e.zip
- Added solutions by Eric Cheung.
- Added solutions by Laurent Rosenfeld. - Added solutions by Ulrich Rieke. - Added solutions by Mark Anderson. - Added solutions by W. Luis Mochan. - Added solutions by E. Choroba. - Added solutions by Feng Chang. - Added solutions by Peter Meszaros. - Added solutions by David Ferrone. - Added solutions by Andrew Shitov. - Added solutions by Peter Campbell Smith. - Added solutions by Asher Harvey-Smith. - Added solutions by Steven Wilson. - Added solutions by Thomas Kohler. - Added solutions by PokGoPun. - Added solutions by Matthew Neleigh. - Added solutions by Robbie Hatley. - Added solutions by Luca Ferrari. - Added solutions by Reinier Maliepaard.
Diffstat (limited to 'challenge-262/eric-cheung/python')
-rwxr-xr-xchallenge-262/eric-cheung/python/ch-1.py9
-rwxr-xr-xchallenge-262/eric-cheung/python/ch-2.py16
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-262/eric-cheung/python/ch-1.py b/challenge-262/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..c0148e39ce
--- /dev/null
+++ b/challenge-262/eric-cheung/python/ch-1.py
@@ -0,0 +1,9 @@
+
+## arrInt = [-3, 1, 2, -1, 3, -2, 4] ## Example 1
+## arrInt = [-1, -2, -3, 1] ## Example 2
+arrInt = [1, 2] ## Example 3
+
+arrPos = [nElem for nElem in arrInt if nElem > 0]
+arrNeg = [nElem for nElem in arrInt if nElem < 0]
+
+print (max(len(arrPos), len(arrNeg)))
diff --git a/challenge-262/eric-cheung/python/ch-2.py b/challenge-262/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..b5c88d67c4
--- /dev/null
+++ b/challenge-262/eric-cheung/python/ch-2.py
@@ -0,0 +1,16 @@
+
+from itertools import combinations
+
+## Example 1
+## arrInt = [3, 1, 2, 2, 2, 1, 3]
+## nK = 2
+
+## Example 2
+arrInt = [1, 2, 3]
+nK = 1
+
+arrCombList = combinations(range(len(arrInt)), 2)
+
+arrOutput = [arrIndxLoop for arrIndxLoop in list(arrCombList) if arrInt[arrIndxLoop[0]] == arrInt[arrIndxLoop[1]] and arrIndxLoop[0] * arrIndxLoop[1] % nK == 0]
+
+print (len(arrOutput))