diff options
| author | Simon Green <mail@simon.green> | 2022-08-28 18:46:24 +1000 |
|---|---|---|
| committer | Simon Green <mail@simon.green> | 2022-08-28 18:46:24 +1000 |
| commit | ebd856ad7f9be363073598af45a200d448cef9c8 (patch) | |
| tree | 86c383877d6324fc6ac9f8b72002842d3addaad0 /challenge-179/sgreen/python/ch-2.py | |
| parent | d41a919cdc74a72e0fab7031b12130325692dcc8 (diff) | |
| download | perlweeklychallenge-club-ebd856ad7f9be363073598af45a200d448cef9c8.tar.gz perlweeklychallenge-club-ebd856ad7f9be363073598af45a200d448cef9c8.tar.bz2 perlweeklychallenge-club-ebd856ad7f9be363073598af45a200d448cef9c8.zip | |
sgreen solutions to challenge 179
Diffstat (limited to 'challenge-179/sgreen/python/ch-2.py')
| -rwxr-xr-x | challenge-179/sgreen/python/ch-2.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-179/sgreen/python/ch-2.py b/challenge-179/sgreen/python/ch-2.py new file mode 100755 index 0000000000..7647b00b1e --- /dev/null +++ b/challenge-179/sgreen/python/ch-2.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +import sys + + +def main(strings): + numbers = [float(x) for x in strings] + bar = '▁▂▃▄▅▆▇█' + barcount = len(bar) + + mn, mx = min(numbers), max(numbers) + extent = mx - mn + sparkline = ''.join(bar[min([barcount - 1, + int((n - mn) / extent * barcount)])] + for n in numbers) + print(sparkline) + + +if __name__ == '__main__': + main(sys.argv[1:]) |
