TITLE ^

Sudoku - A sudoku solver

OVERVIEW ^

This program implements scanning and blocked rows or columns invalidation. It does not consider all effects of multiple number blocking, where a combination of invalid numbers blocks a row or column. In such cases a simple backtracking algorithm continues to solve the sudoku.

SYNOPSIS ^

  parrot -Ot sudoku.pir [--options] [file]

If no file is given a builtin game is run.

Valid options are:

--version

Print version information and exit.

--help

Print help hint and exit.

--debug

Print debug output and game progress to stdout.

--inv=n..

Print additionally invalid state of given number(s).

--builtin=name

Run builtin game. If no name is given a list of builtins is printed.

--nc

Use ncurses for display and single step through progress. Press any key for next display.

DESCRIPTION ^

The game state is held in multiple views which share one Integer PMC per common position. Thus updating a row sets also the column or square information. These three views are list of lists.

GAME FILES ^

Game files may contain comments (hash sign in the first column) digits, and dots for empty fields. E.g:

  # std020.sud
  # der standard 020 - leicht
  2.1..678.
  ...2...36
  8.9.3...5
  .7...4..2
  ..6.9.5..
  9..5...6.
  5...4.9.7
  71...3...
  .987..2.3

PARROT ^

Parrot features used ^

Parrot OO

The solver is an object as well as the display.

Freeze/thaw

For deep copying the game state for backtracking.

Multi Method Dispatch

The display classes define multiple methods with the name print, which take different types and amounts of arguments.

Libraries

The program uses Getopt/Long and the ncurses library.

Exception handling

To turn off ncurses just in case.

Sudoku Class attributes ^

rows, cols, sqrs

LoL of 0 = free, 1..9 = number

i_rows, i_cols, i_sqrs

LoL of a bitmask of invalid numbers per field. Bits are starting at bit one not zero.

all

Hash referencing these 6 items - used for backtracking.

opt

The option hash.

disp

Holds an instance of the display class (Dummy, NCurses) to use.

AUTHOR ^

Leopold Toetsch

COPYRIGHT ^

Same as parrot.


parrot