Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
set solution in Clear category for How to Find Friends by Amachua
def check_connection(n, f1, f2):
a = []
for l in n:
tmp = set(l.split('-'))
for i in range(len(a)):
s = a.pop(0)
if s & tmp: tmp|=s
else: a.append(s)
if f1 in tmp and f2 in tmp: return True
a.append(tmp)
return False
June 13, 2014