Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
super solution in Uncategorized category for Friends by gyahun_dash
from itertools import chain
def getmembers(pairs):
return set(chain.from_iterable(pairs))
class Friends(list):
def __init__(self, pairs):
super().__init__(pairs)
def add(self, pair):
if pair in self: return False
super().append(pair)
return True
def remove(self, pair):
if pair not in self: return False
super().remove(pair)
return True
def names(self):
return getmembers(self)
def connected(self, name):
return getmembers(pair for pair in self if name in pair) - {name}
Nov. 11, 2014
Comments: