one-file-projects/number_of_ways.py

21 lines
339 B
Python
Raw Normal View History

2014-11-04 13:02:25 +01:00
def number_of_ways(numbers):
s = sum(numbers)
if s%3 != 0:
return 0
s = s/3
t = 2*s
u,v,w = 0,0,0
for x in numbers[:-1]:
print( (u,v,w) )
u += x
if u==t:
w+=v
if u==s:
v+=1
return w
if __name__ == "__main__":
print( number_of_ways([0]*4) )