Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Einstein Problem-Lite by flpo
GROUPS = {
"number": {'1', '2', '3', '4', '5'},
"color": {'blue', 'green', 'red', 'white', 'yellow'},
"nationality": {'Brit', 'Dane', 'German', 'Norwegian', 'Swede'},
"beverage": {'beer', 'coffee', 'milk', 'tea', 'water'},
"cigarettes": {'Rothmans', 'Dunhill', 'Pall Mall', 'Winfield', 'Marlboro'},
"pet": {'cat', 'bird', 'dog', 'fish', 'horse'}
}
def answer(relations, question):
from itertools import product
relations = tuple(set(r.split('-')) for r in relations)
owner, group = question.split('-')
houses = (h for h in map(set, product(*GROUPS.values()))
if owner in h and all(len(h & r) != 1 for r in relations))
return (next(houses) & GROUPS[group]).pop()
Aug. 27, 2017
Comments: