aboutsummaryrefslogtreecommitdiff
path: root/challenge-263/eric-cheung/python
diff options
context:
space:
mode:
authorAndrew Shitov <mail@andreyshitov.com>2024-04-02 08:55:46 +0200
committerAndrew Shitov <mail@andreyshitov.com>2024-04-02 08:55:46 +0200
commit58863a39e4fb0cf8abb304d475ea35f2d25800c8 (patch)
tree4642a321cf9eecd993babd7e4345ce84a8148c0c /challenge-263/eric-cheung/python
parent6ccd059d128a87bfcc67d42046bb4cf67a1a40af (diff)
parent6e3cd6e8a2eb65b0ba00b4e15e1abeb689a33e8d (diff)
downloadperlweeklychallenge-club-58863a39e4fb0cf8abb304d475ea35f2d25800c8.tar.gz
perlweeklychallenge-club-58863a39e4fb0cf8abb304d475ea35f2d25800c8.tar.bz2
perlweeklychallenge-club-58863a39e4fb0cf8abb304d475ea35f2d25800c8.zip
Merge remote-tracking branch 'upstream/master' into ash-263
Diffstat (limited to 'challenge-263/eric-cheung/python')
-rwxr-xr-xchallenge-263/eric-cheung/python/ch-1.py16
-rwxr-xr-xchallenge-263/eric-cheung/python/ch-2.py18
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-263/eric-cheung/python/ch-1.py b/challenge-263/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..7c330e0eda
--- /dev/null
+++ b/challenge-263/eric-cheung/python/ch-1.py
@@ -0,0 +1,16 @@
+
+## Example 1
+## arrInt = [1, 5, 3, 2, 4, 2]
+## nK = 2
+
+## Example 2
+## arrInt = [1, 2, 4, 3, 5]
+## nK = 6
+
+## Example 3
+arrInt = [5, 3, 2, 4, 2, 1]
+nK = 4
+
+arrOutput = [nIndxLoop for nIndxLoop, elemLoop in enumerate(sorted(arrInt)) if elemLoop == nK]
+
+print (arrOutput)
diff --git a/challenge-263/eric-cheung/python/ch-2.py b/challenge-263/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..b50b2084d7
--- /dev/null
+++ b/challenge-263/eric-cheung/python/ch-2.py
@@ -0,0 +1,18 @@
+
+## Example 1
+## arrItem_01 = [[1, 1], [2, 1], [3, 2]]
+## arrItem_02 = [[2, 2], [1, 3]]
+
+## Example 2
+## arrItem_01 = [[1, 2], [2, 3], [1, 3], [3, 2]]
+## arrItem_02 = [[3, 1], [1, 3]]
+
+## Example 3
+arrItem_01 = [[1, 1], [2, 2], [3, 3]]
+arrItem_02 = [[2, 3], [2, 4]]
+
+arrCombine = arrItem_01 + arrItem_02
+arrUniq = set([arrLoop[0] for arrLoop in arrCombine])
+arrOutput = [[elemLoop, sum([arrLoop[1] for arrLoop in arrCombine if arrLoop[0] == elemLoop])] for elemLoop in arrUniq]
+
+print (arrOutput)