aboutsummaryrefslogtreecommitdiff
path: root/challenge-267/adam-russell/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-267/adam-russell/python/ch-1.py')
-rw-r--r--challenge-267/adam-russell/python/ch-1.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-267/adam-russell/python/ch-1.py b/challenge-267/adam-russell/python/ch-1.py
new file mode 100644
index 0000000000..47f228adb7
--- /dev/null
+++ b/challenge-267/adam-russell/python/ch-1.py
@@ -0,0 +1,16 @@
+def product_sign(ints):
+ z = list(filter(lambda x: x == 0, ints))
+ if(len(z) > 0):
+ return 0
+ n = list(filter(lambda x: x < 0, ints))
+ if(len(n) % 2 == 1):
+ return -1
+ elif(len(n) > 0 and len(n) % 2 == 0):
+ return 1
+
+ints = (-1, -2, -3, -4, 3, 2, 1)
+print(product_sign(ints))
+ints = (1, 2, 0, -2, -1)
+print(product_sign(ints))
+ints = (-1, -1, 1, -1, 2)
+print(product_sign(ints))