diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-03-26 12:20:13 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-03-26 12:20:13 +0100 |
| commit | 0268632e64340f543178e3438a8ce741c3b775d4 (patch) | |
| tree | dc5898a9c7594fd1675e109781b535182ca1e5d7 /challenge-209/eric-cheung/python | |
| parent | e654b9a8e0b8cb51c472c474d80c9b71affb892a (diff) | |
| download | perlweeklychallenge-club-0268632e64340f543178e3438a8ce741c3b775d4.tar.gz perlweeklychallenge-club-0268632e64340f543178e3438a8ce741c3b775d4.tar.bz2 perlweeklychallenge-club-0268632e64340f543178e3438a8ce741c3b775d4.zip | |
- Added solutions by Mark Anderson.
- Added solutions by James Smith.
- Added solutions by Feng Chang.
- Added solutions by Luca Ferrari.
- Added solutions by Bob Lied.
- Added solutions by Thomas Kohler.
- Added solutions by Vamsi Meenavilli.
- Added solutions by W. Luis Mochan.
- Added solutions by Dave Jacoby.
- Added solutions by Lubos Kolouch.
- Added solutions by Niels van Dijke.
- Added solutions by Flavio Poletti.
- Added solutions by Peter Campbell Smith.
- Added solutions by Roger Bell_West.
- Added solutions by Paulo Custodio.
- Added solutions by Robbie Hatley.
- Added solutions by Jorg Sommrey.
- Added solutions by David Ferrone.
- Added solutions by Mariano Spadiccini.
- Added solutions by Arne Sommer.
- Added solutions by E. Choroba.
- Added solutions by Carlos Oliveira.
- Added solutions by Pip Stuart.
- Added solutions by Matthew Neleigh.
- Added solutions by Laurent Rosenfeld.
- Added solutions by Robert DiCicco.
- Added solutions by Ulrich Rieke.
Diffstat (limited to 'challenge-209/eric-cheung/python')
| -rwxr-xr-x | challenge-209/eric-cheung/python/ch-1.py | 27 | ||||
| -rwxr-xr-x | challenge-209/eric-cheung/python/ch-2.py | 27 |
2 files changed, 54 insertions, 0 deletions
diff --git a/challenge-209/eric-cheung/python/ch-1.py b/challenge-209/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..b6dadfb137 --- /dev/null +++ b/challenge-209/eric-cheung/python/ch-1.py @@ -0,0 +1,27 @@ +
+def IsLastCharA(arrToLoad):
+
+ if len(arrToLoad) % 2 == 0:
+ return False
+
+ if len(arrToLoad) == 1 and arrToLoad[0] == 0:
+ return True
+
+ for nIndx in range(0, len(arrToLoad) - 2, 2):
+ if arrToLoad[nIndx:nIndx + 2] != [1, 0] and arrToLoad[nIndx:nIndx + 2] != [1, 1]:
+ return False
+
+ if arrToLoad[-1] == 0:
+ return True
+
+ return False
+
+
+arrInput = [1, 0, 0] ## Example 1
+## arrInput = [1, 1, 1, 0] ## Example 2
+
+
+if IsLastCharA(arrInput):
+ print ("1")
+else:
+ print ("0")
diff --git a/challenge-209/eric-cheung/python/ch-2.py b/challenge-209/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..624ac7029f --- /dev/null +++ b/challenge-209/eric-cheung/python/ch-2.py @@ -0,0 +1,27 @@ +
+## arrAccount = [["A", "a1@a.com", "a2@a.com"], ["B", "b1@b.com"], ["A", "a3@a.com", "a1@a.com"]] ## Example 1
+arrAccount = [["A", "a1@a.com", "a2@a.com"], ["B", "b1@b.com"], ["A", "a3@a.com"], ["B", "b2@b.com", "b1@b.com"]] ## Example 2
+
+arrUser = [arrAccount[0][0]]
+arrEmail = [arrAccount[0][1:]]
+arrFinal = []
+
+for nIndx in range(1, len(arrAccount)):
+ if arrAccount[nIndx][0] not in arrUser:
+ arrUser.append(arrAccount[nIndx][0])
+ arrEmail.append(arrAccount[nIndx][1:])
+ else:
+ nFindIndx = arrUser.index(arrAccount[nIndx][0])
+ if len(list(set(arrEmail[nFindIndx]) & set(arrAccount[nIndx][1:]))) == 0:
+ arrUser.append(arrAccount[nIndx][0])
+ arrEmail.append(arrAccount[nIndx][1:])
+ else:
+ arrEmail[nFindIndx] = sorted(list(set(arrEmail[nFindIndx] + arrAccount[nIndx][1:])))
+
+## print (arrUser)
+## print (arrEmail)
+
+for nIndx in range(0, len(arrUser)):
+ arrFinal.append([arrUser[nIndx], str(arrEmail[nIndx][:])[1:-1]])
+
+print (arrFinal)
|
