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 StanislauL
def is_family(tree):
sons, oldest = [], set()
for pair in tree:
if pair[1] in sons or [pair[1],pair[0]] in tree: return False
sons.append(pair[1])
oldest.discard(pair[1])
if pair[0] not in sons: oldest.add(pair[0])
if len(oldest)!=1: return False
return True
Nov. 28, 2017