Ryan Byrd dot net

Sudoku (or Su Doku):

Sudoku is a Japanese number/logic game I recently discovered on a flight from Cleveland to Salt Lake. The gentleman seated to my left was feverishly jotting down numbers in his book which contained a 9x9 grid of numbers and spaces. To satisfy my curiousity, I leaned over and asked him about it. Here's what he said:

There are just 3 rules to Sudoku:

  1. Each row must have the numbers 1-9 occuring just once.
  2. Each column must have the numbers 1-9 occuring just once.
  3. And the numbers 1-9 must occur just once in each of the 9 sub-boxes of the grid.
Got it?

Basic strategy

There are a number of ways to solve these puzzles. Here's one way: Basically, you go through each square and write down the list of possible values (given the constraints imposed by the columns and rows and 3x3 grid). You'll get something like this:

Then you go through and try to eliminate possibilities (trial and error, logic, etc.) until you've finished! Interested? There are four puzzles below, in increasing difficulty, for you to try out.

Oh, in case you're wondering, Sudoku is Japanese for "the digits must remain single"

Sudoku links:

Here's my pseudocode design for a Sudoku generator:

UPDATE: this code isn't very good. it will generate invalid boards that have the same numbers in a row or column. a better way would be to generate complete boards and remove numbers, the move numbers you remove the harder it will be

initialize 9 $smallBoards (3x3 grid)
initialize $largeBoard with those 9 $smallBoards

function ObtainCandidateValues ($largeBoard, $row, $column)
{
  get possible (candidate) values from a $smallBoard
  get candidate values from the $largeBoard row
  get candidate values from the $largeBoard column
  return $CVlist;
}

Main loop:

create a random list of reference to each of the 9 smallBoards
for each smallBoard in that list
{
  if $difficulty_level==hard, pick a number from 0 to 5, set it equal to the variable $places 
  if $difficulty_level==medium, pick a number from 2 to 4, set it equal to the variable $places
  if $difficulty_level==easy, pick a number from 3 to 5, set it equal to the variable $places
  create a list $places random locations (inside a $smallBoard)
  for each of those random locations
  {
     ObtainCandidateValues for that location
     randomly choose a value from the list and assign it to the location
  }
}									

Sample Sudoku puzzles

Easy Sudoku for 6-3-2006

 549   3 
9  12 7  
     6918
 8  9 6 2
 7 3 2 8 
4 1 6  9 
7465     
  2 38  1
 1   456 
Sudoku provided by Sudoku.com.au


Medium Sudoku for 6-3-2006

 85   47 
    8    
 9145   6
     37 9
7       1
1 37     
9   2853 
    7    
 78   21 
Sudoku provided by Sudoku.com.au


Hard Sudoku for 6-3-2006

    4 9  
   1  24 
      8 3
69   8  1
 3 7 2 5 
2  3   94
5 3      
 26  7   
  8 6    
Sudoku provided by Sudoku.com.au


Tough Sudoku for 6-3-2006

 9  7 6  
   5  2  
  5  1 7 
8  2    7
    4    
6    7  4
 3 6  9  
  1  4   
  8 5  2 
Sudoku provided by Sudoku.com.au


Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2008, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah