aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/sgreen/python/ch-2.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2024-01-21 21:43:03 +1100
committerSimon Green <mail@simon.green>2024-01-21 21:43:03 +1100
commit50431906f587a0d8622ac4714edb64e612facc11 (patch)
tree8cd837b23558d98378ebd5219df6028b4f0b6a23 /challenge-252/sgreen/python/ch-2.py
parent7efb373bb9adffa79f84825217015835805298b5 (diff)
downloadperlweeklychallenge-club-50431906f587a0d8622ac4714edb64e612facc11.tar.gz
perlweeklychallenge-club-50431906f587a0d8622ac4714edb64e612facc11.tar.bz2
perlweeklychallenge-club-50431906f587a0d8622ac4714edb64e612facc11.zip
Simon's solution to challenge 252
Diffstat (limited to 'challenge-252/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-252/sgreen/python/ch-2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-252/sgreen/python/ch-2.py b/challenge-252/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..745338701a
--- /dev/null
+++ b/challenge-252/sgreen/python/ch-2.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(n):
+ solution = []
+ half = n // 2
+
+ # If we have an odd number, add a zero
+ if n % 2 == 1:
+ solution = [0]
+
+ for i in range(half):
+ # Add a pair of numbers
+ solution.insert(0, -i-1)
+ solution.append(i+1)
+
+ print(*solution, sep=', ')
+
+
+if __name__ == '__main__':
+ # Convert input into integers
+ main(int(sys.argv[1]))