Files
pyDefis/Sommer de 1 et des -1.py
Francois JUMELLE 20526d93c8 Initial release
2021-05-03 22:32:40 +02:00

19 lines
1.1 KiB
Python

input = [1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1]
# input = [1, -1, 1, 1, 1, -1, -1, 1]
sol = [(0, (0,0,0))]
for a in range(len(input)+1):
for b in range(1, len(input)-a+1):
for c in range(len(input)-a-b+1):
l = input[a::b][:c]
if sum(l) > sol[0][0]:
sol = [(sum(l), (a,b,c)),]
# print("meilleur", sol)
elif sum(l) == sol[0][0]:
sol.append((sum(l), (a,b,c)))
# print("egal", sol)
for s in sol:
print(s)