Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Simple Sudoku Solver
Ruby Perl
Branch: master


Yet Another Sudoku Solver

The Blame

Blame for this code base goes to Dave Hoover (@redsquirrel), who started it all by twittering about working on a Sudoku solver (

The Past

I wrote a very simple Sudoku solver a couple years ago. My coworkers introduced me to the puzzle and spent their lunchtimes solving them. I solved one or two by hand and realized that I would enjoy writing a program to solve them rather than solving them myself.

That early version of the program could only handle simple sudoku puzzles that didn’t involve guessing and backtraking. Unfortunately that early version has been lost in the mists if time.

The Present

This new version of the solver was written from scratch and does handle tougher puzzles the require guessing and backtracking. Except for the puzzle parsing code, it doesn’t share any implementation with Dave’s solution.


Just pass it the name of the puzzle file (.sud) on the command line. It will print out the initial and final puzzles, and each step along the way to a solution.


ruby sudoku.rb puzzles/evil.sud

And It Continues

It seems that Corey Haines (@coreyhaines) has also caught the Sudoku solver bug and has posted his solution (


You are granted permission to read, copy, modify, redistribute this software or derivatives of this software.

Something went wrong with that request. Please try again.