Zebra puzzle solver

Type in any zebra puzzle (also called Einstein's riddle or a logic grid puzzle) and this solver works it out in your browser. It tells you whether the clues give no answer, exactly one answer or more than one, shows the solved grid, and says whether a person could solve it by plain elimination or needs a "what if" step.
How to use the zebra puzzle solver
- Set the size. Choose how many positions are in the row (3 to 6, for example five houses) and how many categories there are (2 to 6, for example colour, pet and drink).
- Name the categories and values. Open "Change the names" and type the words your puzzle uses, such as "Nationality: Brit, Swede, Dane". You can skip this and use the ready-made names.
- Add the clues one at a time. Pick the clue type from the list, then the values it talks about. The line under the boxes shows the clue as a sentence so you can check it matches your puzzle, then tap "Add clue".
- Read the answer. The solver runs again every time you add or remove a clue. When it says "Exactly one answer", the grid underneath is the solution.
Want to see it working first? Tap one of the "Load an example" buttons to fill in Einstein's riddle, either the "who owns the fish?" version or the 1962 "who owns the zebra?" version. Your work is saved on this device, so a refresh does not lose it. "Start again" clears everything.
What each clue type means
A clue is always about one, two or three values, called A, B and C below. Positions are counted from the left, so position 1 is the far left. The clue types guide explains each one with an example and what it lets you cross off.
| Clue type | Means |
|---|---|
| A goes with B | A and B are in the same position (the Brit lives in the red house). |
| A does not go with B | A and B are in different positions. |
| A is in a given position | A is in that exact place, such as position 3. |
| A is not in a given position | A is anywhere except that place. |
| A is at one of the ends | A is in the first or the last position. |
| A is directly left (or right) of B | A and B are neighbours, in that order. |
| A is next to B | A and B are neighbours, either way round. |
| A is not next to B | A and B are not neighbours. They may be in the same position if they are from different categories. |
| A is somewhere left (or right) of B | A is further left than B, with any gap. |
| Exactly one position between A and B | A and B are two places apart, either way round. |
| B is somewhere between A and C | B is further right than one of them and further left than the other. |
| A goes with B or with C, but not both | A is in the same position as exactly one of B and C. |
Puzzles often word clues in other ways. "The coffee drinker lives in the green house" is "coffee goes with green". "The man who smokes Blends lives next to the one who keeps cats" is "Blends is next to cats". In the fish version loaded here, "the green house is on the left of the white house" is read as directly left.
What the three results mean
| Result | What it means | What to do |
|---|---|---|
| No answer | The clues contradict each other: no arrangement fits all of them. | Look for a mistyped value or a left that should be a right. If the puzzle had answers before your last clue, the solver says so. |
| Exactly one answer | The puzzle is complete and the grid shown is the only solution. | Read the grid. The note under it says whether plain elimination is enough or a "what if" step is needed. |
| More than one answer | The clues so far allow several arrangements. | The grid shown is only one possibility. Values with a dotted outline can change, so add clues about them. |
A good zebra puzzle has exactly one answer and can be solved by reasoning alone. If you are writing your own, the guide on how to make a zebra puzzle explains how to use this kind of check, and the zebra puzzle generator makes a new puzzle for you.
How the solver works
It runs two separate checks, using the same code that checks every daily Zriddle puzzle.
It solves the way a person would. It starts with every value possible in every position, then reads each clue and crosses off what that clue rules out. It also uses the rule that each value sits in a different position, so a value with only one place left goes there. If that gets stuck, it tries pair reasoning: two values that can only go in the same two places block those places for everything else. If that is still not enough, it tries a "what if" step: suppose a value is in a place, follow the clues, and if something breaks, cross that place off. The deepest of these steps it needed is what the result reports.
It counts the answers. Separately, it searches through the arrangements, filling in one value at a time and dropping any branch that breaks a clue, until it has found two answers or run out of options. That is how it knows for certain whether there is no answer, one answer or more than one. A category that no clue mentions is left out of the search, because its values could go anywhere.
A very large puzzle with few clues can take a long time to search. If a search runs for more than 15 seconds the solver stops and asks you to add or check clues.
Is my puzzle private?
Yes. Everything runs in your browser on your own device. Your clues and names are not sent anywhere. They are saved in your browser's local storage so they are still there after a refresh, and "Start again" deletes them.
Zebra puzzle solver FAQ
Can it solve Einstein's riddle?
Yes. Tap "Einstein's riddle (fish)" or "Einstein's riddle (zebra)" to load the full set of clues. Both have exactly one answer: the German owns the fish, and in the zebra version the Japanese man owns the zebra and the Norwegian drinks water. The Einstein riddle answer page walks through the fish version step by step.
Why does the zebra version need a "what if" step?
Because its clues never let you finish by reading one clue at a time. At some point you have to suppose a value is in a place, follow the clues, and see that it breaks one. The fish version can be finished by plain elimination.
What sizes does it handle?
From 3 to 6 positions and 2 to 6 categories, which covers the classic five houses with five categories and every Zriddle daily puzzle, including Expert (6 positions, 5 categories).
Can I type the clues in as sentences?
No. You pick each clue from the lists instead, so there is no chance of the solver misreading a sentence. The line under the boxes shows the clue in words before you add it, so you can compare it with your puzzle.
Is using a solver cheating?
Only if you want it to be. It is handy for checking a puzzle you wrote, or for finding out whether a puzzle you are stuck on really has one answer. For practice, the solving strategies guide shows the same steps the solver uses, and a new daily puzzle is waiting on the home page.
