aboutsummaryrefslogtreecommitdiff
path: root/challenge-179/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2024-10-22 18:11:56 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2024-10-22 18:11:56 +0100
commit45c413ded143a3d7548e837e2cc459f4fabcda41 (patch)
treeb82f0097d81f98326854e90cddbfaa9ff9613c15 /challenge-179/paulo-custodio/python/ch-2.py
parentc3edc9149c2c1d435eecf347139ca83094e1d86e (diff)
downloadperlweeklychallenge-club-45c413ded143a3d7548e837e2cc459f4fabcda41.tar.gz
perlweeklychallenge-club-45c413ded143a3d7548e837e2cc459f4fabcda41.tar.bz2
perlweeklychallenge-club-45c413ded143a3d7548e837e2cc459f4fabcda41.zip
Add Python solutions
Diffstat (limited to 'challenge-179/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-179/paulo-custodio/python/ch-2.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-179/paulo-custodio/python/ch-2.py b/challenge-179/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..02019cb832
--- /dev/null
+++ b/challenge-179/paulo-custodio/python/ch-2.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+# Challenge 179
+#
+# Task 2: Unicode Sparkline
+# Submitted by: Mohammad S Anwar
+#
+# You are given a list of positive numbers, @n.
+#
+# Write a script to print sparkline in Unicode for the given list of numbers.
+
+import sys
+
+bars = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"]
+
+nums = list(map(int, sys.argv[1:]))
+max_num = max(nums)
+height = [int((num / max_num) * 7) for num in nums]
+chars = [bars[h] for h in height]
+print(''.join(chars))