View Source Backfish.Examples.Sudoku (Backfish v0.1.0)

An implementation of the Sudoku puzzle using the Backfish backtracking library.

Sudoku is a logic-based combinatorial number-placement puzzle. The objective is to fill a 9x9 grid with digits so that each column, each row, and each of the nine 3x3 subgrids that compose the grid contain all of the digits from 1 to 9.

Summary

Functions

Returns the initial state of the Sudoku puzzle.

Checks if the given state is a goal state.

Generates the next possible states from the given state.

Functions

Returns the initial state of the Sudoku puzzle.

Parameters

  • args: A keyword list of arguments. Expects :board which is a 2D list representing the initial board configuration.

Returns

  • A map representing the initial state, including the board and the board size.

Checks if the given state is a goal state.

Parameters

  • state: The current state of the problem, which includes the board configuration and the board size.

Returns

  • true if all cells in the board contain numbers from 1 to the board size, false otherwise.

Generates the next possible states from the given state.

Parameters

  • state: The current state of the problem, which includes the board configuration and the board size.

Returns

  • A list of the next possible states, each including the new board configuration with one additional number placed.