Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Break Rings by LMAO
from itertools import chain, combinations
def break_rings(connections):
rings = set(chain(*connections))
for num in range(1, len(rings)):
for broken_rings in combinations(rings, num):
# 'connection' will be broken when it intersect with 'set(broken_rings)'
if all(connection & set(broken_rings) for connection in connections):
return num
Feb. 21, 2015