Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Break Rings by wrap
from functools import reduce
def break_rings(rings):
N = max(reduce(set.union, rings))
def f(s, k):
if N < k:
return len(s)
else:
ok = all([{x, k} not in rings for x in s])
return max(f(s, k+1), f(s+[k], k+1) if ok else 0)
return N - f([], 1)
Sept. 24, 2015