aboutsummaryrefslogtreecommitdiff
path: root/challenge-263/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-04-01 18:17:24 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-04-01 18:17:24 +0100
commit6e3cd6e8a2eb65b0ba00b4e15e1abeb689a33e8d (patch)
tree9651d8a04663c80427d748c4be9886260db3031f /challenge-263/eric-cheung/python/ch-2.py
parent0c72fe827b8dcc33de40b2dd35fad3b38fdb06a2 (diff)
downloadperlweeklychallenge-club-6e3cd6e8a2eb65b0ba00b4e15e1abeb689a33e8d.tar.gz
perlweeklychallenge-club-6e3cd6e8a2eb65b0ba00b4e15e1abeb689a33e8d.tar.bz2
perlweeklychallenge-club-6e3cd6e8a2eb65b0ba00b4e15e1abeb689a33e8d.zip
- Added solutions by Mark Anderson.
- Added solutions by Thomas Kohler. - Added solutions by Feng Chang. - Added solutions by Peter Meszaros. - Added solutions by Andrew Shitov. - Added solutions by Steven Wilson. - Added solutions by W. Luis Mochan. - Added solutions by James Smith. - Added solutions by Wanderdoc. - Added solutions by Laurent Rosenfeld. - Added solutions by Eric Cheung.
Diffstat (limited to 'challenge-263/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-263/eric-cheung/python/ch-2.py18
1 files changed, 18 insertions, 0 deletions
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)