aboutsummaryrefslogtreecommitdiff
path: root/challenge-308/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-02-10 20:39:47 +0000
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-02-10 20:39:47 +0000
commite9d030e5fd8fa107797fac1489bca6ce2724d212 (patch)
tree67b923088c999951deb2282143353932210d2cdf /challenge-308/eric-cheung/python
parenta4ee687a84267a19ebcb6d9228ffe4f73927396b (diff)
downloadperlweeklychallenge-club-e9d030e5fd8fa107797fac1489bca6ce2724d212.tar.gz
perlweeklychallenge-club-e9d030e5fd8fa107797fac1489bca6ce2724d212.tar.bz2
perlweeklychallenge-club-e9d030e5fd8fa107797fac1489bca6ce2724d212.zip
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke. - Added solutions by Mark Anderson. - Added solutions by David Ferrone. - Added solutions by Ali Moradi. - Added solutions by Niels van Dijke. - Added solutions by Peter Pentchev. - Added solutions by E. Choroba. - Added solutions by Peter Meszaros. - Added solutions by Thomas Kohler. - Added solutions by W. Luis Mochan. - Added solutions by BarrOff.
Diffstat (limited to 'challenge-308/eric-cheung/python')
-rwxr-xr-xchallenge-308/eric-cheung/python/ch-1.py16
-rwxr-xr-xchallenge-308/eric-cheung/python/ch-2.py19
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-308/eric-cheung/python/ch-1.py b/challenge-308/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..e05d16d0b8
--- /dev/null
+++ b/challenge-308/eric-cheung/python/ch-1.py
@@ -0,0 +1,16 @@
+
+## Example 1
+## arrStr_01 = ["perl", "weekly", "challenge"]
+## arrStr_02 = ["raku", "weekly", "challenge"]
+
+## Example 2
+## arrStr_01 = ["perl", "raku", "python"]
+## arrStr_02 = ["python", "java"]
+
+## Example 3
+arrStr_01 = ["guest", "contribution"]
+arrStr_02 = ["fun", "weekly", "challenge"]
+
+arrCommon = [strLoop for strLoop in arrStr_01 if strLoop in arrStr_02]
+
+print (len(arrCommon))
diff --git a/challenge-308/eric-cheung/python/ch-2.py b/challenge-308/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..3aaa8972ac
--- /dev/null
+++ b/challenge-308/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+## Ref.
+## If c = a ^ b, then a = c ^ b or a = b ^ c
+## Similarly, b = c ^ a or b = a ^ c
+
+## Example 1
+## arrEncoded = [1, 2, 3]
+## nInitial = 1
+
+## Example 2
+arrEncoded = [6, 2, 7, 3]
+nInitial = 4
+
+arrOutput = [nInitial]
+
+for nElem in arrEncoded:
+ arrOutput.append(arrOutput[-1] ^ nElem)
+
+print (arrOutput)