This logic grid puzzle solver is for the classic "who lives where and owns what" puzzles: a few categories, the same number of items in each, and clues that tie them together. You type your own puzzle, the solver finds the answer, and Next step walks you through it one deduction at a time while the grid of checks and crosses fills in. It works as a general logic puzzle solver for any puzzle of this shape, up to 5 categories of 6.
How to enter a logic puzzle
- Choose how many categories there are and how many items each has. Name each category and type its items separated by commas. Tick ordered for a category whose items have an order, such as ages, house numbers or times.
- Build each clue from a template and pick the items from the lists, then press Add clue. The templates cover the usual wording: A is B; A is not B; A is lower or higher than B; A is next to B; A is N more or less than B; A is either B or C; of A and B, one is C and the other is D; exactly one of two statements is true; and a group of items that are all different.
- Press Solve. If the clues allow more than one answer, the solver says how many (up to 50) and shows two side by side with the differences marked, so you can see what a missing clue needs to separate. If no answer fits, it says the clues contradict each other.
Clues often hide a rule in their wording. "The person in house 2 is not Ben" is a plain A is not B clue. "Ana lives somewhere left of the dog owner" is A is lower than B in the House category.
Worked example: four neighbors on Maple Row
Ana, Ben, Cleo and Dev live in houses 1 to 4. Each has one pet (cat, dog, parrot, rabbit) and one favorite drink (coffee, juice, milk, tea). The clues: 1. House 4 is milk. 2. Ben is not house 4. 3. Dev and Ben are next to each other. 4. The dog is either Ana's or Cleo's. 5. Juice is either Ben's or Cleo's. 6. The cat owner does not drink tea. 7. The parrot's house number is 3 more than the juice drinker's. 8. Of juice and tea, one goes with the cat and the other with the rabbit. 9. Of the cat and the rabbit, one is in house 1 and the other in house 3.
Clue 8 says the cat owner drinks juice or tea, and clue 6 rules out tea, so the cat owner drinks juice and the rabbit owner drinks tea. Clue 7 then puts the juice drinker in house 1 and the parrot in house 4. Load the example to follow all the steps; the answer is Ana in house 2 with the dog and coffee, Ben in house 3 with the rabbit and tea, Cleo in house 1 with the cat and juice, and Dev in house 4 with the parrot and milk. This puzzle was written for this page.
How the solver works
The solver keeps the same grid you would: for every pair of items, yes, no or unknown. It applies the clues, then the grid rules: a check mark rules out the rest of its row and column, a row with one option left gets a check, and two facts that share an item link up (if Ana is the cat owner and the cat owner drinks juice, Ana drinks juice). Ordered and either/or clues trim the options that cannot work. When none of this helps, it tests an assumption and keeps it only if it leads to a contradiction, which it then explains. To find every solution and prove there are no others, it combines these rules with a search, and each answer is checked against all the clues before it is shown.
Solving tip
Mark the crosses for every "not" clue first, then look for rows with a single gap; each new check mark copies all the facts of one item onto the other.
Another puzzle of pure deduction is Mastermind, where each score rules out codes the way each clue here rules out pairs. For number clues on a grid, see the nonogram solver.
Solver tested . Found a problem? Tell us.
Questions
What kind of logic puzzles can this solve?
Grid logic puzzles (also called Einstein or zebra-style puzzles) with 2 to 5 categories of 2 to 6 items each, where every item of one category goes with exactly one item of each other category. Clues must fit one of the templates; most published clues do once rephrased.
Why does it say there are several solutions?
The clues you entered do not pin down one answer. Often a clue was left out or entered with the wrong template. The solver shows two answers with the differences marked, which tells you where the missing information is.
How do I enter 'A is somewhere to the left of B'?
Tick ordered for the category that has the order (for example House, with items 1 to 4 from left to right), then use the template 'A is lower or earlier than B' with that category. For 'directly left of' use 'A is N less than B' with N = 1.
What does 'of A and B, one is C and the other is D' mean?
It means A and B are two different entries, and C and D go with them in some order: either A is C and B is D, or A is D and B is C.
Can it explain every step?
For puzzles that have one answer, it explains each deduction from the grid rules and the clues, and uses an explained assumption when the simple rules stall. If a puzzle can only be finished by trial and error, the steps stop there and Solve gives the answer.