Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
14-liner: yeap solution in Clear category for The Einstein Problem-Lite by przemyslaw.daniel
NUMBERS = ['1', '2', '3' , '4', '5']
COLORS = ['blue', 'green', 'red', 'white', 'yellow']
NATIONALITY = ['Brit', 'Dane', 'German', 'Norwegian', 'Swede']
BEVERAGE = ['beer', 'coffee', 'milk', 'tea', 'water']
CIGARETTES = ['Rothmans', 'Dunhill', 'PallMall', 'Winfield', 'Marlboro']
PET = ['cat', 'bird', 'dog', 'fish', 'horse']
ALL = {'number' : NUMBERS, 'color' : COLORS, 'nationality' : NATIONALITY,
'beverage' : BEVERAGE, 'cigarettes' : CIGARETTES, 'pet' : PET}
def answer(pairs, question):
f = lambda k, p: [(x in k)^(y in k) for x, y in [x.split('-') for x in p]]
for i in __import__('itertools').product(*ALL.values()):
if question.split('-')[0] not in i or any(f(i, pairs)): continue
return [x for x in i if x in ALL[question.split('-')[1]]][0]
April 15, 2017
Comments: