24 lines
546 B
Python
24 lines
546 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
from itertools import combinations_with_replacement as comb
|
||
|
|
||
|
bound = 200
|
||
|
sieve = [i-1 for i in range(bound+1)]
|
||
|
dup = []
|
||
|
|
||
|
def rec(chain, sieve, bound, id=0):
|
||
|
c = 1
|
||
|
for m in chain:
|
||
|
n = m+chain[0]
|
||
|
if n > bound:
|
||
|
continue
|
||
|
if len(chain) >= max(sieve[n:n+3]): #<-- trial and error magic
|
||
|
continue
|
||
|
if len(chain) < sieve[n]:
|
||
|
sieve[n] = len(chain)
|
||
|
c += rec([n] + chain, sieve, bound, id+1)
|
||
|
return c
|
||
|
|
||
|
rec([1], sieve, bound)
|
||
|
print(sum(sieve[2:]))
|