aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/steve-g-lynn/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-252/steve-g-lynn/python/ch-2.py')
-rw-r--r--challenge-252/steve-g-lynn/python/ch-2.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-252/steve-g-lynn/python/ch-2.py b/challenge-252/steve-g-lynn/python/ch-2.py
new file mode 100644
index 0000000000..3947e22c8c
--- /dev/null
+++ b/challenge-252/steve-g-lynn/python/ch-2.py
@@ -0,0 +1,15 @@
+# python 1.4 beta on DOSBOX
+
+def unique_sum_zero(n):
+ retval=[]
+ if ((n % 2) > 0):
+ retval.append(0)
+ for i in range(n/2):
+ retval.append(-(i+1))
+ retval.append(i+1)
+ return retval
+
+print unique_sum_zero(5) #[0,-1,1,-2,2]
+print unique_sum_zero(3) #[0,-1,1]
+print unique_sum_zero(1) #[0]
+