Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sets, inner sets, recursion solution in Clear category for How to Find Friends by AmaroVita
def check_connection(network, first, second):
network = set(map(lambda x:frozenset(x.split('-')),network))
def check_set(n,f,s):
if {f,s} in n:
return True
else:
for x in [x for x in n if f in x]:
if check_set(n-{x},(set(x)-{f}).pop(),s):
return True
return False
return check_set(network,first,second)
Feb. 21, 2015