diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-04-25 12:01:15 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-04-25 12:01:15 +0100 |
| commit | c2faea053751fb6a48e1ddaab1476ccac3336376 (patch) | |
| tree | d5588fa97a2d32cdd93c49285c36003e04dd3cbb /challenge-214/eric-cheung/python | |
| parent | 54033b87b27ef65cdb9d3292b6c5125375e42101 (diff) | |
| download | perlweeklychallenge-club-c2faea053751fb6a48e1ddaab1476ccac3336376.tar.gz perlweeklychallenge-club-c2faea053751fb6a48e1ddaab1476ccac3336376.tar.bz2 perlweeklychallenge-club-c2faea053751fb6a48e1ddaab1476ccac3336376.zip | |
- Added solutions by Mark Anderson.
- Added solutions by Lubos Kolouch.
- Added solutions by David Ferrone.
Diffstat (limited to 'challenge-214/eric-cheung/python')
| -rwxr-xr-x | challenge-214/eric-cheung/python/ch-1.py | 12 | ||||
| -rwxr-xr-x | challenge-214/eric-cheung/python/ch-2.py | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-214/eric-cheung/python/ch-1.py b/challenge-214/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..ea68026c42 --- /dev/null +++ b/challenge-214/eric-cheung/python/ch-1.py @@ -0,0 +1,12 @@ +
+arrInputScore = [1, 2, 4, 3, 5] ## Example 1
+## arrInputScore = [8, 5, 6, 7, 4] ## Example 2
+## arrInputScore = [3, 5, 4, 2] ## Example 3
+## arrInputScore = [2, 5, 2, 1, 7, 5, 1] ## Example 4
+
+arrUniqSortScore = list(set(arrInputScore))
+arrUniqSortScore = arrUniqSortScore[::-1]
+arrInterRank = [max(arrUniqSortScore.index(nElem), len([1 for nLoop in arrInputScore if nLoop > nElem])) for nElem in arrInputScore]
+arrOutputRank = ["G" if nElem == 0 else "S" if nElem == 1 else "B" if nElem == 2 else nElem + 1 for nElem in arrInterRank]
+
+print (arrOutputRank)
diff --git a/challenge-214/eric-cheung/python/ch-2.py b/challenge-214/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..323352eaf9 --- /dev/null +++ b/challenge-214/eric-cheung/python/ch-2.py @@ -0,0 +1,11 @@ +
+## arrNum = [2, 4, 3, 3, 3, 4, 5, 4, 2] ## Example 1
+## arrNum = [1, 2, 2, 2, 2, 1] ## Example 2
+## arrNum = [1] ## Example 3
+arrNum = [2, 2, 2, 1, 1, 2, 2, 2] ## Example 4
+
+arrUniq = list(set(arrNum))
+arrCount = [arrNum.count(nElem) for nElem in arrUniq]
+arrSQ = [nElem * nElem for nElem in arrCount]
+
+print (sum(arrSQ))
|
