Learn R Programming

sudokuAlt (version 0.2-1)

solveGame: Solve a Sudoku Game

Description

Solve a Sudoku Game

Usage

solveGame(game)

Arguments

game

The game to be solved

Value

A solved sudoku game object if one found, or NULL if no solution exists. The original game is attached as an attribute if the game is solved.

Details

Given a sudoku game to be solved, find the solution. IMPORTANT: games are represented as n^2 x n^2 character matrices, using 1-9 for n=2 or 3, and LETTERS[1:(n^2)] for n = 4 or 5.

Examples

Run this code
# NOT RUN {
set.seed(1234)
makeGame(3, gaps = 60) %>% solve %>% plot -> sg
(g <- originalGame(sg))

g <- emptyGame(4)  # construct a patterned game
diag(g) <- LETTERS[1:16]
sg <- solve(g)
plot(sg)
# }

Run the code above in your browser using DataLab