Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
set solution in Clear category for Friends by gyahun_dash
class Friends(set):
def __init__(self, pairs=set()):
super().__init__(map(frozenset, pairs))
def add(self, pair):
if pair in self: return False
super().add(frozenset(pair))
return True
def remove(self, pair):
if pair not in self: return False
super().remove(pair)
return True
def names(self):
return set().union(*self)
def connected(self, name):
return Friends(filter({name}.issubset, self)).names() - {name}
Nov. 14, 2014
Comments: