aboutsummaryrefslogtreecommitdiff
path: root/challenge-193/sgreen/python/ch-1.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2022-12-04 21:13:15 +1100
committerSimon Green <mail@simon.green>2022-12-04 21:13:15 +1100
commit1d1515048145eb2257eca3c6a02de75491e15848 (patch)
tree47f71b6f0f1a2664c59cb1a6afdfa3141eaf2e19 /challenge-193/sgreen/python/ch-1.py
parent7b20d63dc4dba5367930bd615f15e31ac6483747 (diff)
downloadperlweeklychallenge-club-1d1515048145eb2257eca3c6a02de75491e15848.tar.gz
perlweeklychallenge-club-1d1515048145eb2257eca3c6a02de75491e15848.tar.bz2
perlweeklychallenge-club-1d1515048145eb2257eca3c6a02de75491e15848.zip
Simon's solution to challenge 193
Diffstat (limited to 'challenge-193/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-193/sgreen/python/ch-1.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-193/sgreen/python/ch-1.py b/challenge-193/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..7497e1c61d
--- /dev/null
+++ b/challenge-193/sgreen/python/ch-1.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(n):
+ # The format we want (a binary string of a given length)
+ fmt = f'0{n}b'
+
+ # Make a list with all possible binary values
+ l = [format(x, fmt) for x in range(2**n)]
+
+ # Show the list
+ print(*l, sep=', ')
+
+
+if __name__ == '__main__':
+ main(int(sys.argv[1]))