Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Friends by capback250
from itertools import chain
class Friends:
def __init__(self, conn):
self.conn = list(conn)
def add(self, conn):
if conn in self.conn:
return False
else:
self.conn.append(conn)
return True
def remove(self, conn):
if conn in self.conn:
self.conn.remove(conn)
return True
return False
def names(self):
return set(chain(*self.conn))
def connected(self, name):
s = []
[s.extend(list(i)) for i in self.conn if name in i]
s = set(s)
if name in set(s):
s.remove(name)
return s
Feb. 9, 2016