diff options
Diffstat (limited to 'challenge-214/sgreen/python/ch-1.py')
| -rwxr-xr-x | challenge-214/sgreen/python/ch-1.py | 24 |
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) |
