aboutsummaryrefslogtreecommitdiff
path: root/challenge-179/sgreen/python/ch-2.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2022-08-28 18:46:24 +1000
committerSimon Green <mail@simon.green>2022-08-28 18:46:24 +1000
commitebd856ad7f9be363073598af45a200d448cef9c8 (patch)
tree86c383877d6324fc6ac9f8b72002842d3addaad0 /challenge-179/sgreen/python/ch-2.py
parentd41a919cdc74a72e0fab7031b12130325692dcc8 (diff)
downloadperlweeklychallenge-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-xchallenge-179/sgreen/python/ch-2.py20
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:])