Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The Einstein Problem-Lite solution in Clear category for The Einstein Problem-Lite by JimmyCarlos
def answer(clues, question):
elems_all = {"number":{'1', '2', '3', '4', '5'},
"color":{'blue', 'green', 'red', 'white', 'yellow'},
"pet":{'cat', 'bird', 'dog', 'fish', 'horse'},
"beverage":{'beer', 'coffee', 'milk', 'tea', 'water'},
"cigarettes":{'Rothmans', 'Dunhill', 'Pall Mall', 'Winfield', 'Marlboro'},
"nationality":{'Brit', 'Dane', 'German', 'Norwegian', 'Swede'}}
people = list(__import__("itertools").product(*elems_all.values()))
for clue in clues:
a,b = clue.split("-")
people = [person for person in people if not ((a in person) ^ (b in person))]
elem_type=lambda x:[k for k,v in elems_all.items() if x in v][0]
key_person = [person for person in people if question.split("-")[0] in person][0]
return [x for x in key_person if elem_type(x) == question.split("-")[1]][0]
Sept. 21, 2019