Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Friends by UFO665
class Friends:
def __init__(self, connections):
self.connections = list(connections)
def add(self, connection):
if connection not in self.connections:
self.connections.append(connection)
return True
return False
def remove(self, connection):
if connection in self.connections:
self.connections.remove(connection)
return True
return False
def names(self):
s = set()
for name in self.connections:
s.update(name)
return s
def connected(self, name):
s = set()
for conn in self.connections:
if name in conn:
s.update(conn.difference(set([name])))
return s
Dec. 5, 2015