Using the digits 0-9 form five two-digit numbers, which form an arithmetic sequence.
Find the sum of the numbers in all the possible arithmetic sequences that can occur.
total = 0
for a in range (72):
gap = 100-a
maxt2t = (gap//4) + 1
for t2t in range(7,maxt2t):
b, c, d, e = a + t2t, a + 2*t2t, a + 3*t2t, a + 4*t2t
ans = ''.join(sorted(str(a) + str(b) + str(c) + str(d) + str(e)))
if ans == '0123456789' or ans == '123456789':
print(a,b,c,d,e)
total += a + b + c + d + e
print ("Total = ", total)
It gives an output like this:
1 23 45 67 89
5 16 27 38 49
9 18 27 36 45
9 27 45 63 81
10 32 54 76 98
18 36 54 72 90
50 61 72 83 94
54 63 72 81 90
Total = 1980