Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Break Rings by rojeeer
from itertools import chain
from itertools import combinations
def break_rings(rings):
# get number of rings
n_of_rings = max(chain.from_iterable(rings))
for n_of_broken in range(1, n_of_rings):
for c in combinations(range(1, n_of_rings + 1), n_of_broken):
if max([len(edge - set(c)) for edge in rings]) == 1:
return n_of_broken
Nov. 19, 2015