Sudoku - Perl extension for solving Su Doku puzzles
use Games::Sudoku::Board;
my $game = new Games::Sudoku::Board('Game 1', $debug, $pause);
$game->initFromFile($fname);
$game->displayBoard();
$game->solve();
$game->displayBoard();
This module solves Su Doku puzzles. The puzzle must be stored in a file of the following format : nine lines of nine characters where unknown characters presented by zero, e.g
000050380 |
035006090 |
000100000 |
704000001 |
006872000 |
000504600 |
059700800 |
107285000 |
000040700 |
More examples can be found in example directory that comes with distribution
The code then might look like:
#!/usr/bin/perl
use strict;
use warnings;
use Games::Sudoku::Board;
use Getopt::Long;
my ($fname, $pause, $debug) = ('', 0, 0);
GetOptions('file=s' => \$fname, 'pause' => \$pause, 'debug' => \$debug);
my $game = new Games::Sudoku::Board;
$game->initFromFile($fname);
$game->debug($debug);
$game->pause($pause);
$game->displayBoard();
$game->solve();
$game->displayBoard();
- Add board init from a data structure
- Add error handling and invalid layout capture
- Add support for 16x16 boards
Eugene Kulesha, <kulesha@gmail.com>
Copyright (C) 2005 by Eugene Kulesha
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.