Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Human = Robot = Chatter. Say No to discrimination solution in Clear category for Dialogues by V.Shkaberda
class Chat:
def __init__(self):
self.instances, self.dialogue = [], []
self.connect_human = self.connect_robot = \
lambda name: name.connect_to_chat(self.dialogue, self.instances)
self.chat = lambda: (yield from zip(self.instances, self.dialogue))
def show_human_dialogue(self):
return '\n'.join((name + ' said: ' + msg)
for name, msg in self.chat()).strip()
def show_robot_dialogue(self):
return '\n'.join((name + ' said: ' + ''.join(('0' if c in 'aeiou' else '1')
for c in msg.lower()))
for name, msg in self.chat()).strip()
class Chatter:
def __init__(self, name):
self.name = name
def connect_to_chat(self, dialogue, instances):
self.dialogue, self.instances = dialogue, instances
def send(self, msg):
self.dialogue.append(msg)
self.instances.append(self.name)
Human = Robot = Chatter
Aug. 3, 2019