diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-03-19 07:34:59 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-03-19 07:34:59 +0000 |
| commit | 5a46973e2f1fed5547e0e4fb7f1adcf3a3ea525e (patch) | |
| tree | 2336cf3bf456b60630455f0b94c0e8b2044a1b8c /challenge-208/eric-cheung/python | |
| parent | 87e50ae17dae2c587957134a5ec50ecd3a3c6fce (diff) | |
| download | perlweeklychallenge-club-5a46973e2f1fed5547e0e4fb7f1adcf3a3ea525e.tar.gz perlweeklychallenge-club-5a46973e2f1fed5547e0e4fb7f1adcf3a3ea525e.tar.bz2 perlweeklychallenge-club-5a46973e2f1fed5547e0e4fb7f1adcf3a3ea525e.zip | |
- Added solutions by Mark Anderson.
- Added solutions by W. Luis Mochan.
- Added solutions by E. Choroba.
- Added solutions by Feng Chang.
- Added solutions by Lubos Kolouch.
- Added solutions by Thomas Kohler.
- Added solutions by David Ferrone.
- Added solutions by Mariano Spadaccini.
- Added solutions by Peter Campbell Smith.
- Added solutions by Roger Bell_West.
- Added solutions by Robbie Hatley.
- Added solutions by Paulo Custodio.
- Added solutions by Dave Jacoby.
- Added solutions by Bob Lied.
- Added solutions by Luca Ferrari.
- Added solutions by Jorg Sommrey.
- Added solutions by Niels van Dijke.
- Added solutions by Matthew Neleigh.
- Added solutions by James Smith.
- Added solutions by Arne Sommer.
- Added solutions by Carlos Oliveira.
- Added solutions by Ulrich Rieke.
- Added solutions by Avery Adams.
- Added solutions by Robert DiCicco.
- Added solutions by Tyler Bird.
Diffstat (limited to 'challenge-208/eric-cheung/python')
| -rwxr-xr-x | challenge-208/eric-cheung/python/ch-1.py | 23 | ||||
| -rwxr-xr-x | challenge-208/eric-cheung/python/ch-2.py | 13 |
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-208/eric-cheung/python/ch-1.py b/challenge-208/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..15a03253aa --- /dev/null +++ b/challenge-208/eric-cheung/python/ch-1.py @@ -0,0 +1,23 @@ +
+## Example 1
+## arrList_01 = ["Perl", "Raku", "Love"]
+## arrList_02 = ["Raku", "Perl", "Hate"]
+
+## Example 2
+## arrList_01 = ["A", "B", "C"]
+## arrList_02 = ["D", "E", "F"]
+
+## Example 3
+arrList_01 = ["A", "B", "C"]
+arrList_02 = ["C", "A", "B"]
+
+arrCommonList = [strLoop for strLoop in arrList_01 if strLoop in arrList_02]
+
+if len(arrCommonList) > 0:
+ arrCommonIndxSum = [arrList_01.index(strLoop) + arrList_02.index(strLoop) for strLoop in arrCommonList]
+ arrMinIndx = [nIndx for nIndx, nLoop in enumerate(arrCommonIndxSum) if nLoop == min(arrCommonIndxSum)]
+ arrMinList = [arrCommonList[nIndx] for nIndx in arrMinIndx]
+
+ print (arrMinList)
+else:
+ print ([])
diff --git a/challenge-208/eric-cheung/python/ch-2.py b/challenge-208/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..951f8a03a0 --- /dev/null +++ b/challenge-208/eric-cheung/python/ch-2.py @@ -0,0 +1,13 @@ +
+## arrNum = [1, 2, 2, 4] ## Example 1
+## arrNum = [1, 2, 3, 4] ## Example 2
+arrNum = [1, 2, 3, 3] ## Example 3
+
+arrList = range(1, len(arrNum) + 1)
+
+arrDupMiss = list(set([nElemLoop for nElemLoop in arrNum if arrNum.count(nElemLoop) > 1])) + list(set(arrList).difference(set(arrNum)))
+
+if len(arrDupMiss) > 0:
+ print (arrDupMiss)
+else:
+ print (-1)
|
