Psudoku Solver


This page contains the code for a brute-force sudoku solver written in perl. My friend Ben Greenfield told put me up to it by saying it had taken another friend all of Christmas to write a brute-force recursive solution and I didn't see why it should take that long so I built one over a couple of weekends. I call it "Psudoku Solver" because it's not really solving the puzzle through deductive logic. It just guesses all possible numbers in all possible combinations until it finds one that completes the board. (Apparently Ben's other friend solved it in the same way.) Therefore it's a pseudo sudoku-solver or a psudoku-solver, for short. Brute force is lame, I know, but it was a fun problem in enumeration and gave me a good excuse to learn about data structures in perl. A much more interesting solution would employ deductive logic alone. Perhaps I'll try that later (famous last words...)

Feel free to use the code and make it your own. Enjoy.

Directions

You will need a version of perl 5 or later to run this script.
  1. Download the script
  2. Launch a shell terminal
  3. Create an input file with the board you want to solve like this. Let's assume it's called "myboard.txt"
  4. Type perl psudoku-solver.pl myboard.txt
  5. The script will print the answer to stdout.



home