sudoku (version 2.6)

readSudoku: Read a File Containing a Sudoku Grid

Description

Reads a file containing a Sudoku grid (a 9x9 matrix).

Usage

readSudoku(fn, map)

Arguments

fn

A filename.

map

Vector of unique puzzle elements (possibly longer than necessary). The default is c(1:9, letters), so an N=16 puzzle should be encoded using '1'-'9' and 'a'-'g'.

Value

A numeric matrix (usually 9x9).

Details

The input file should look like this:

-6-1-4-5-
--83-56--
2-------1
8--4-7--6
--6---3--
7--9-1--4
5-------2
--72-69--
-4-5-8-7-

Blank cells can be indicated with any character not in "map", such as the '-' used here.

Examples

Run this code
# NOT RUN {
  z <- readSudoku(system.file("puz1.txt", package="sudoku"))
# }

Run the code above in your browser using DataLab