Solving Every Sudoku Puzzle (2006)
Mood
thoughtful
Sentiment
positive
Category
tech
Key topics
Sudoku
Constraint Satisfaction Problems
Algorithm Optimization
The article discusses Peter Norvig's approach to solving Sudoku puzzles using constraint propagation, sparking discussion on optimization techniques and the broader applications of CSP.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
5d
Peak period
12
Day 6
Avg / period
6.8
Based on 27 loaded comments
Key moments
- 01Story posted
Nov 4, 2025 at 9:30 AM EST
20 days ago
Step 01 - 02First comment
Nov 9, 2025 at 4:28 PM EST
5d after posting
Step 02 - 03Peak activity
12 comments in Day 6
Hottest window of the conversation
Step 03 - 04Latest activity
Nov 12, 2025 at 3:54 PM EST
11 days ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Uses constraint propagation, not any specialized sudoku solving algorithms. But this person is a CSP expert and finds ways to optimize CSP for sudoku in particular.
… And then does it all in SIMD.
this is the example that made me finally understand how to embed NO complete problems into other NP complete problems.
and this mofo wrote zero code yet tricked a programming language into doing work anyway
In my testing, 25x25 Sudokus are algorithmically challenging. Solving times for a naive but well-tuned algorithm with reasonable heuristics can easily be on the order of an hour for a single puzzle. A smart system with advanced reasoning can be many orders of magnitude faster.
It does backtracking with recursion. It uses bitwise operations for fast conflict detection in rows, columns and 3x3 blocks. But one very important heuristics is that it firstly sorts the cells in such a way that the backtracking brute force starts from the most densely filled side. This eliminates a lot of wrong branches early, and actually helps a lot. I'm thinking maybe I can extend this to 16x16 or 25x25 as well. Not sure if this will scale up adequately. But this one usually cracks puzzles in a fraction of second. It only become slow for extremely hard killer sudoku puzzles.
const randomNumbers = random ? [1, 2, 3, 4, 5, 6, 7, 8, 9].sort(() => Math.random() - 0.5).sort(() => Math.random() - 0.5) : null
does not really do what you seem to intend. Sort requires a comparison function that is stable, and there are a lot of things that could go wrong if this is not supplied.For shuffling, use a shuffle algorithm. Fisher-Yates is the common suggestion on what to use.
The specification says that if the comparator is not a consistent comparator, the sort order is implementation defined: https://tc39.es/ecma262/multipage/indexed-collections.html#s... Further along, it is specified that only if the sort order is correct, are you guaranteed to get a permutation of the input as the result. I would not write code expecting this to work.
For a list of interesting instances to test, see this file: https://github.com/Gecode/gecode/blob/release/6.3.0/examples...
I should probably do some benchmarks on that with the standard MiniZinc solvers.
> As computer security expert Ben Laurie has stated, Sudoku is "a denial of service attack on human intellect". Several people I know (including my wife) were infected by the virus, and I thought maybe this would demonstrate that they didn't need to spend any more time on Sudoku.
Ah, yes... remember the halcyon days of 2006, when something as benign as Sudoku was considered to be a "denial of service attack on human intellect"?
The same could be said about every logic puzzle, or other types of puzzles.
People don't do them so actually solve any sort of new problem, or achieve some sort of productivity.
The same reason people don’t jog to get from point A to point B, or to learn how to get around more quickly.
Logic puzzles are exercising parts of our brain that don’t get exercised regularly.
If any, the challenge and fun would come by solving them with an algorithm under its favourite programming language.
Also, lateral thinking based riddles/puzzles are often more fun to solve, such as the crime related ones.
Then I got interested in devising puzzles with multiple solutions. Not too difficult. But making a few puzzles with two solutions was fun.
Experiment_203(
" 1 . . | 2 . 8 | . . 9 "+
" . 8 . | . . . | . 3 . "+
" . . 7 | . 1 . | 2 . . "+
//------+-------+--------
" 4 . . | 1 2 3 | . . 6 "+
" . . 2 | 4 5 6 | 9 . . "+
" 6 . . | 7 8 9 | . . 4 "+
//------+-------+--------
" . . 6 | . 4 . | 8 . . "+
" . 2 . | . . . | . 7 . "+
" 9 . . | 8 . 2 | . . 1 "
),
// Solution #1. Found in 0 days 00:00:00.004.// 245 boards examined so far.
1 6 5 | 2 3 8 | 7 4 9
2 8 4 | 6 9 7 | 1 3 5
3 9 7 | 5 1 4 | 2 6 8
------+-------+------
4 7 9 | 1 2 3 | 5 8 6
8 3 2 | 4 5 6 | 9 1 7
6 5 1 | 7 8 9 | 3 2 4
------+-------+------
7 1 6 | 3 4 5 | 8 9 2
5 2 8 | 9 6 1 | 4 7 3
9 4 3 | 8 7 2 | 6 5 1
// Solution #2. Found in 0 days 00:00:00.001.// 287 boards examined so far.
1 6 5 | 2 3 8 | 7 4 9
2 8 4 | 9 6 7 | 1 3 5 // <-- 9 6 7 instead of 6 9 7
3 9 7 | 5 1 4 | 2 6 8
------+-------+------
4 7 9 | 1 2 3 | 5 8 6
8 3 2 | 4 5 6 | 9 1 7
6 5 1 | 7 8 9 | 3 2 4
------+-------+------
7 1 6 | 3 4 5 | 8 9 2
5 2 8 | 6 9 1 | 4 7 3 // <-- 6 9 1 instead of 9 6 1
9 4 3 | 8 7 2 | 6 5 1
2 total solutions found.
304 total boards examined.
Total time 0 days 00:00:00.041.
Then I got to looking at difficult puzzles on the web. Apparently AI escargot is the world's most difficult. (And the site http://www.aisudoku.com/index_en.html says I can't publish the board). So I'll only publish the stats of applying my solver to it. Solution #1. Found in 0 days 00:00:00.029.
3,906 boards examined so far.
1 total solutions found.
7,832 total boards examined.
Total time 0 days 00:00:00.085.What a wonderful time saver! Now you can get back to the important work of doing the dishes and folding laundry, and don't feel the need to personally participate in the denial of service attack on human intellect going on here.
Sounds like social media feeds these days
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.