Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Pure solution in Creative category for How to Find Friends by nicuveo
from functools import reduce
from operator import or_
def check_connection(n, f, s):
g = reduce(or_, (set(((a, b), (b, a))) for a, b in (e.split("-") for e in n)))
i = lambda c: reduce(or_, (set(e[1] for e in g if e[0] == x) for x in c))
p = lambda a, c: s in c or (c and p(a | c, i(c) - a))
return bool(p(set(), {f}))
June 6, 2014
Comments: