Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
if(a in b) solution in Clear category for Friends by PawlakBartosz43
class Friends:
def __init__(self, connections):
self.con = []
for i in connections:
if(not(i in self.con)):
self.con.append(i)
def add(self, connection):
if(connection in self.con):
return False
self.con.append(connection)
return True
def remove(self, connection):
if(connection in self.con):
self.con.remove(connection)
return True
return False
def names(self):
nam = set()
for i in self.con:
for x in i:
nam.add(x)
return nam
def connected(self, name):
nams = set()
for i in self.con:
if(name in i):
nams.update(i)
nams.discard(name)
return nams
Nov. 6, 2016