Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for What Is Wrong With This Family? by FromVault13
def is_family(tree):
fathers = [i[0] for i in tree]
sons = [i[1] for i in tree]
if len(sons) > len(set(sons)): return False
if len(set(fathers) - set(sons)) != 1: return False
family = {i[1]: i[0] for i in tree}
for key,value in family.items():
if key == value: return False
if value in family.keys():
if family[value] == key: return False
return True
Aug. 30, 2017