one-file-projects/number_of_ways.py

20 lines
339 B
Python

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) )