Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
no loops, just filter solution in Clear category for What Is Wrong With This Family? by xndrllyd
def is_family(tree):
f, s = zip(*tree)
return (
not any( # not stranger in the family
filter(
lambda x: not (
x[0] in s or x[1] in f
) if f.count(x[0]) == 1
and len(tree) > 1
else None, tree
)
)
and not any( # not father to your father
filter(
lambda x: tree.count(x[::-1]) >= 1, tree
)
)
and len(f) == len(set(s)) # not father to your brother
)
Dec. 27, 2020