Hard sudoku: the techniques you need when the basics run out
Hidden pairs, pointing pairs, X-Wing, forcing chains and a method for when you are stuck. The techniques that crack a 26-clue sudoku, explained without jargon.
There is a moment in the life of everyone who does sudoku that is easy to recognise: the easy ones solve themselves, the medium ones take a while, and the hard ones always stall at the same point. You fill twenty cells in one go, and then suddenly there is not a single cell you can place with confidence.
That point is not a lack of practice. It is that you have run out of the techniques you know.
This article is about the ones that come next. If you have not yet got the hang of the only candidate and cross-hatching, start with the step-by-step guide; this is the next rung up.
First: mark properly, or none of this works
Every technique below is applied to the candidates you have marked, not to the bare grid. And marking badly is the number one reason a hard sudoku becomes impossible.
Two rules:
Do not mark everything. Filling in the candidates for all 81 cells from the start leaves you with an unreadable board in which nothing stands out. Mark only where you have narrowed things to two or three possibilities.
Update as you place. Every number you commit invalidates candidates in its row, its column and its box. If you do not cross them off at that moment, half an hour later you will be reasoning on false information — and that error does not announce itself, it just propagates.
1. Hidden pairs
You already know naked pairs: two cells in the same unit whose only candidates are the same pair, say {4,9}. That lets you delete the 4 and the 9 from the rest of the unit.
The hidden pair is the same idea in reverse, and that is why it gets missed far more often.
Look for two numbers that, within a unit, can only go in the same two cells. It does not matter if those cells also carry other candidates. If the 3 and the 7 only fit in cells A and B of this box, then A and B are the 3 and the 7 in some order, and every other candidate in A and B can be deleted.
The practical difference: a naked pair is spotted by looking at cells, a hidden pair by looking at numbers. And since almost nobody makes that second pass, it is the technique that most often unsticks a board that looked dead.
The same works with triples, though they are harder to see: three numbers that only fit in three cells.
2. Pointing pairs
This one is easier to apply than its name suggests.
Look at a box and pick a number that is not yet placed in it. If all the cells where that number could go inside the box are in the same row, then that number is in that row, within this box, even though you do not know which cell.
And from that comes the deduction: that number cannot be anywhere else in that row, outside the box. Cross it off.
Same with columns. It is one of the highest-yield techniques for how little it costs to look for: pick a number, go box by box, and check whether its candidates are aligned.
3. Box/line reduction
The reverse of the previous one, and usually forgotten.
Look at a row and pick a number. If all the cells where it could go in that row are inside the same box, then that number is in that box, and you can delete it from the rest of the box.
The two go together: when you find an alignment between a box and a line, always check both directions before moving on. Half the time the second one gives you something too.
4. X-Wing
This one has an intimidating name and a simple logic. It is the first of the genuinely advanced techniques, and with it you can solve many sudokus that seem to require guessing.
Look for a number — say the 5 — that in two different rows can only go in the same two columns.
col B col F
row 2 [5?] ...... [5?]
row 7 [5?] ...... [5?]
The four cells form a rectangle. And here is the reasoning: the 5 in row 2 is in B or in F. The one in row 7, likewise. But they cannot both be in the same column, because then that column would have two fives.
So: either it is in B2 and F7, or in F2 and B7. Either way, columns B and F already have their 5 inside that rectangle. You can delete the 5 from every other cell in columns B and F.
It works the same starting from columns and eliminating in rows. It takes effort to spot the first time and then comes quickly: look for numbers with exactly two candidates in a row, and check whether another row has the same two.
5. Forcing chains, the last resort
When nothing else is left, you can reason like this: «suppose this cell is a 4». Follow the forced consequences as far as they go. If they lead to a contradiction — a row with two identical numbers, a cell with no candidates — then it was not a 4, and you have just solved the cell.
This is not guessing, even though it looks like it. Guessing is writing a number down and carrying on. This is proof by contradiction: you only commit something once you have shown the alternative is impossible.
Two warnings:
- Do it in your head or in very light pencil. If you write the chain on the board and it turns out there was no contradiction, you have to unwind the whole thing and it is easy to miss a step.
- Start from cells with two candidates. With three, the branches multiply and you get lost.
In a well-built sudoku of reasonable difficulty this is almost never needed. If you find yourself reaching for chains in a «medium», you have probably missed a hidden pair.
A method for being stuck
More useful than any single technique: what to do when you cannot see anything. A fixed order, so you do not go round in circles.
- Check the nearly-full units. Rows, columns and boxes missing one or two cells. It is the first thing people overlook after placing several numbers in a row.
- Change the question. If you have spent a while asking «what goes in this cell», switch to «where can this number go» and run through all nine. Most deadlocks are about perspective, not difficulty.
- Look for hidden pairs, number by number, unit by unit. This is where the answer turns up nine times out of ten.
- Look for box↔line alignments in both directions.
- Look for an X-Wing among the numbers with few candidates.
- And only then, a forcing chain from a two-candidate cell.
If you have been through all six and it still will not come out, check whether you made a mistake earlier. In a sudoku with a verified unique solution, a complete deadlock almost always means there is a wrong number twenty moves back.
A note on difficulty
Difficulty is usually measured by the number of starting clues: 40 for easy, 32 for medium, 26 for hard. That is the convention, and it is approximate.
What really determines how hard a sudoku is is not how many clues it has, but which techniques it demands and how the clues are spread. A 30-clue grid with a bad distribution may call for an X-Wing; a 26-clue one may fall to the only candidate. That is why there are «easy» sudokus that stall and «hard» ones that collapse in one pass.
What must always be guaranteed is that the solution is unique. If at some point you have to choose between two equally valid options with no contradiction available, the problem is not you: the puzzle is badly built. In our sudokus it is checked one by one as they are generated, and the same goes for the printable ones.
If you want to know where all this comes from, the history of sudoku is better than you would expect: it was invented by an architect in Indiana, not by anyone Japanese.