For comparison, here is my own solution in Python 3 to the Zebra Puzzle. To me this solution seems sorter and easier to understand:
from itertools import permutations as perms
houses = range(1,6) # houses numbered 1,2,3,4,5
for Englishman, Spaniard, Ukrainian, Norwegian, Japanese in perms(houses):
if Norwegian != 1: continue # rule 10
for red, green, ivory, yellow, blue in perms(houses):
if Englishman != red: continue # rule 2
if green != ivory + 1: continue # rule 6
if Norwegian not in [blue-1,blue+1]: continue # rule 15
for coffee, tea, milk, oj, water in perms(houses):
if coffee != green: continue # rule 4
if Ukrainian != tea: continue # rule 5
if milk != 3: continue # rule 9
for oldgold, kools, chesterfields, luckys, parliaments in perms(houses):
if kools != yellow: continue # rule 8
if luckys != oj: continue # rule 13
if Japanese != parliaments: continue # rule 14
for dog, snails, fox, horse, zebra in perms(houses):
if Spaniard != dog: continue # rule 3
if oldgold != snails: continue # rule 7
if chesterfields not in [fox-1,fox+1]: continue # rule 11
if kools not in [horse-1, horse+1]: continue # rule 12
person = {Englishman: 'Englishman', Spaniard: 'Spainard',
Ukrainian: 'Ukrainian', Norwegian: 'Norwegian', Japanese: 'Japanese'}
print(f'{person[water]} drinks water')
print(f'{person[zebra]} owns the zebra')