Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Exception mishandling solution in Creative category for What Is Wrong With This Family? by veky
from contextlib import suppress
def is_family(tree):
with suppress(AssertionError, RecursionError):
f = {}
for father, son in tree:
assert son not in f
f[son] = father
def oldest_ancestor(person):
with suppress(KeyError):
return oldest_ancestor(f[person])
return person
patriarchs = set(map(oldest_ancestor, f))
return len(patriarchs) == 1
return False
Oct. 7, 2016
Comments: