aboutsummaryrefslogtreecommitdiff
path: root/challenge-214/sgreen/python/ch-1.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2023-05-03 22:56:38 +1000
committerSimon Green <mail@simon.green>2023-05-03 22:56:53 +1000
commitaa9582ae6d8027dbf73cfe4a1b106b331c5a0362 (patch)
tree62428be859e434706d4ba6a0e681dc6e1aa4c0a1 /challenge-214/sgreen/python/ch-1.py
parentfd65867cfebbaf4ebdd5aed901c3c71d20e31d16 (diff)
downloadperlweeklychallenge-club-aa9582ae6d8027dbf73cfe4a1b106b331c5a0362.tar.gz
perlweeklychallenge-club-aa9582ae6d8027dbf73cfe4a1b106b331c5a0362.tar.bz2
perlweeklychallenge-club-aa9582ae6d8027dbf73cfe4a1b106b331c5a0362.zip
Simon's solution to challenge 214
Diffstat (limited to 'challenge-214/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-214/sgreen/python/ch-1.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-214/sgreen/python/ch-1.py b/challenge-214/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..35bd25744a
--- /dev/null
+++ b/challenge-214/sgreen/python/ch-1.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import sys
+
+
+def main(array):
+ score_to_place = {}
+ for i, score in enumerate(sorted(array, reverse=True)):
+ if score not in score_to_place:
+ score_to_place[score] = i+1
+
+ place_to_word = {1: 'G', 2: 'S', 3: 'B'}
+ solution = []
+ for i in array:
+ place = score_to_place[i]
+ solution.append(place_to_word.get(place, place))
+
+ print(*solution, sep=', ')
+
+
+if __name__ == '__main__':
+ # Turn the strings into integers
+ n = [int(i) for i in sys.argv[1:]]
+ main(n)