The Zebra Puzzle

Open frontend (this MVC app) rendering data from a secured backend API. The API key stays server-side — the browser never sees it.

The puzzle

  1. There are five houses.
  2. The Englishman lives in the red house.
  3. The Spaniard owns the dog.
  4. Coffee is drunk in the green house.
  5. The Ukrainian drinks tea.
  6. The green house is immediately to the right of the ivory house.
  7. The Old Gold smoker owns snails.
  8. Kools are smoked in the yellow house.
  9. Milk is drunk in the middle house.
  10. The Norwegian lives in the first house.
  11. Chesterfields are smoked next to the house with the fox.
  12. Kools are smoked next to the house with the horse.
  13. The Lucky Strike smoker drinks orange juice.
  14. The Japanese smokes Parliaments.
  15. The Norwegian lives next to the blue house.

Result

✓ Solved in 129 ms — 5 houses (via BE).

House 1 2 3 4 5
Nationality Norwegian Ukrainian Englishman Spaniard Japanese
Color Yellow Blue Red Ivory Green
Drink Water Tea Milk Orange juice Coffee
Smoke Kools Chesterfields Old Gold Lucky Strike Parliaments
Pet Fox Horse Snails Dog Zebra

The Norwegian drinks water. The Japanese owns the zebra.

Search-space collapse

Column legend — each column A1…E5 is one property; its value is the house sequence (1–5) that property occupies.

A Nationality A1 Englishman · A2 Spaniard · A3 Ukrainian · A4 Norwegian · A5 Japanese
B Color B1 Red · B2 Green · B3 Ivory · B4 Yellow · B5 Blue
C Drink C1 Coffee · C2 Tea · C3 Milk · C4 Orange juice · C5 Water
D Smoke D1 Old Gold · D2 Kools · D3 Chesterfields · D4 Lucky Strike · D5 Parliaments
E Pet E1 Dog · E2 Snails · E3 Fox · E4 Horse · E5 Zebra

Each role is a permutation of 5 values → 5! = 120, so the sample space is 120⁵ = 24,883,200,000. The backend reports how many arrangements remain after clues 1…k (the counting method itself stays server-side).

#ConstraintCombinations remaining
1 There are five houses. 24,883,200,000
2 The Englishman lives in the red house. 4,976,640,000
3 The Spaniard owns the dog. 995,328,000
4 Coffee is drunk in the green house. 199,065,600
5 The Ukrainian drinks tea. 37,324,800
6 The green house is immediately to the right of the ivory house. 7,464,960
7 The Old Gold smoker owns snails. 1,492,992
8 Kools are smoked in the yellow house. 300,672
9 Milk is drunk in the middle house. 55,584
10 The Norwegian lives in the first house. 8,208
11 Chesterfields are smoked next to the house with the fox. 2,400
12 Kools are smoked next to the house with the horse. 804
13 The Lucky Strike smoker drinks orange juice. 145
14 The Japanese smokes Parliaments. 32
15 The Norwegian lives next to the blue house. 1