aboutsummaryrefslogtreecommitdiff
path: root/challenge-267/adam-russell/python/ch-1.py
blob: 47f228adb7fde6b807098a36ff9bc881b7af94d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))