diff options
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:]) |
