playSudoku | R Documentation |
Interactively play a game of 9x9 Sudoku with hints and undo
playSudoku(z=NULL, hist.len=100, solve=TRUE, display=c("guess","windows","tk"), hscale=1.25, vscale=1.25, ...)
z |
Either a 9x9 numeric matrix representing the Sudoku grid
(with '0' representing a blank cell), or 0 (zero) for an empty
matrix, or a filename (passed to |
hist.len |
Integer representing the number of history steps to remember (number of undo's possible). |
solve |
Logical indicating if the solution should be computed (used for checking current answer or cheating). |
display |
Type of display. The default 'guess' uses a windows graphics device if getOption('device')=='windows', otherwise it uses tk (requiring the 'tkrplot' package). |
hscale |
Passed to tkrplot |
vscale |
Passed to tkrplot |
... |
Arguments passed to |
To play, move the mouse arrow over an empty cell and press the number key to enter the number in the cell. Typing '?' brings up a menu of additional commands:
? -- a short help message 1-9 -- insert digit 0,' ' -- clear cell r -- replot the puzzle q -- quit h -- hint/help c -- correct wrong entries (show in red) u -- undo last entry s -- show number in cell a -- show all (solve the puzzle)
An invisible matrix with the solution or current state of the puzzle. Save this if you stop part way through, and use it as the input for the function to start again where you left off (undo info is lost so make sure that everything is correct).
display='windows' makes use of the getGraphicsEvent
function, which currently only works on Windows.
Greg Snow greg.snow@intermountainmail.org and David E. Brahm <brahm@alum.mit.edu>
solveSudoku
## Not run: puz1 <- playSudoku(0) # Use as an editor to create a puzzle, then quit sol1 <- playSudoku(puz1) # now play the puzzle puz2 <- edit(matrix(0,9,9)) # Or use this editor sol2 <- playSudoku(puz2) # now play the puzzle playSudoku() # Play a randomly generated game playSudoku(fetchSudokuUK()) # Play today's game ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.