Package sudoku. February 20, 2015



Similar documents
Package retrosheet. April 13, 2015

Welcome to the topic on Master Data and Documents.

Package sjdbc. R topics documented: February 20, 2015

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Macros in Word & Excel

Package fimport. February 19, 2015

The resulting tile cannot merge with another tile again in the same move. When a 2048 tile is created, the player wins.

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

AP Computer Science Java Mr. Clausen Program 9A, 9B

PARALLELIZED SUDOKU SOLVING ALGORITHM USING OpenMP

Genetic Algorithms and Sudoku

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Package hive. January 10, 2011

Microsoft Excel v5.0 Database Functions

Package MBA. February 19, Index 7. Canopy LIDAR data

A Review of Sudoku Solving using Patterns

3 IDE (Integrated Development Environment)

SMART NOTEBOOK 10. Instructional Technology Enhancing ACHievement

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

Integrated Accounting System for Mac OS X

Package RCassandra. R topics documented: February 19, Version Title R/Cassandra interface

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Package HadoopStreaming

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Excel Project From the Start menu select New Office Document. If necessary, click the General tab and then double-click Blank workbook.

Sudoku puzzles and how to solve them

Package sendmailr. February 20, 2015

Package TSfame. February 15, 2013

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

Microsoft Word 2010 Training

MAKE YOUR FIRST A-MAZE-ING GAME IN GAME MAKER 7

3.GETTING STARTED WITH ORACLE8i

Package neuralnet. February 20, 2015

Microsoft Access 2010 Overview of Basics

SOAL-SOAL MICROSOFT EXCEL 1. The box on the chart that contains the name of each individual record is called the. A. cell B. title C. axis D.

Sudoku Madness. Team 3: Matt Crain, John Cheng, and Rabih Sallman

ADDING DOCUMENTS TO A PROJECT. Create a a new internal document for the transcript: DOCUMENTS / NEW / NEW TEXT DOCUMENT.

Package png. February 20, 2015

How to Concatenate Cells in Microsoft Access

Package plan. R topics documented: February 20, 2015

Solving Systems of Linear Equations Using Matrices

No restrictions are placed upon the use of this list. Please notify us of any errors or omissions, thank you,

UNIVERSITY OF CALGARY Information Technologies WEBFORMS DRUPAL 7 WEB CONTENT MANAGEMENT

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

AAFCO Check Sample Program New Data Reporting Website Manual Date of Issue: March 1 st 2014

Microsoft Access 3: Understanding and Creating Queries

Working with Tables: How to use tables in OpenOffice.org Writer

Package decompr. August 17, 2016

CGS2531 Problem Solving Using Computer Software Sample Exam 3. Select the most appropriate answer(s).

Project 2: Bejeweled

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Package pxr. February 20, 2015

Section IV.1: Recursive Algorithms and Recursion Trees

Package uptimerobot. October 22, 2015

Using Microsoft Project 2000

Package treemap. February 15, 2013

Excel I Sorting and filtering Revised February 2013

Using Microsoft Word. Working With Objects

Integrated Invoicing and Debt Management System for Mac OS X

Package pdfetch. R topics documented: July 19, 2015

Package hive. July 3, 2015

EXCEL SOLVER TUTORIAL

Creating Database Model Diagrams in Microsoft Visio Jeffery S. Horsburgh

Level 15: Creating a Puzzle

Microsoft PowerPoint 2011

Education Solutions Development, Inc. APECS Navigation: Business Systems Getting Started Reference Guide

MS Project Tutorial for Senior Design Using Microsoft Project to manage projects

Website Creator Pro Quick Reference Guide. Version: 0.5

Move between open workbooks. Display the print menu. Select whole spreadsheet. Microsoft Excel Keyboard Keys. General

RECURSIVE COMMON TABLE EXPRESSIONS DATABASE IN ORACLE. Iggy Fernandez, Database Specialists INTRODUCTION

Adding Comments in Microsoft Excel 2003

Setting up a basic database in Access 2003

Package hoarder. June 30, 2015

IN THE WORKSHOP Tip #14

AEI RAIL & ROAD MANAGER

Figure Error! No text of specified style in document..1: Project Organization

After you complete the survey, compare what you saw on the survey to the actual questions listed below:

RIT Installation Instructions

SPSS for Windows importing and exporting data

not at all a manual simply a quick how-to-do guide

Construction Administrators Work Smart with Excel Programming and Functions. OTEC 2014 Session 78 Robert Henry

This activity will show you how to draw graphs of algebraic functions in Excel.

EXCEL FINANCIAL USES

Access Tutorial 1 Creating a Database

Microsoft PowerPoint 2010

HIT THE GROUND RUNNING MS WORD INTRODUCTION

Appointments Module. User s Manual

Kenken For Teachers. Tom Davis June 27, Abstract

WHAT S NEW IN MS EXCEL 2013

paragraph(s). The bottom mark is for all following lines in that paragraph. The rectangle below the marks moves both marks at the same time.

Automated Inventory System

Package httprequest. R topics documented: February 20, 2015

Getting Started with Access 2007

Package erp.easy. September 26, 2015

Online Test Monitor Certification Course Transcript

LabVIEW Day 6: Saving Files and Making Sub vis

PA2: Word Cloud (100 Points)

Web Intelligence User Guide

Transcription:

Version 2.6 Date 2014-06-30 Title Sudoku Puzzle Generator and Solver Package sudoku February 20, 2015 Author David Brahm <brahm@alum.mit.edu> and Greg Snow <Greg.Snow@intermountainmail.org>, with contributions from Curt Seeliger <Seeliger.Curt@epamail.epa.gov> and Henrik Bengtsson <hb@maths.lth.se>. Maintainer David Brahm <brahm@alum.mit.edu> Suggests tkrplot Generates, plays, and solves Sudoku puzzles. The GUI playsudoku() needs package ``tkrplot'' if you are not on Windows. License GPL NeedsCompilation no Repository CRAN Date/Publication 2014-07-01 00:51:36 R topics documented: fetchsudokuuk....................................... 2 generatesudoku....................................... 3 hintsudoku......................................... 4 playsudoku......................................... 4 printsudoku......................................... 6 readsudoku......................................... 7 solvesudoku......................................... 8 writesudoku......................................... 9 Index 10 1

2 fetchsudokuuk fetchsudokuuk Fetch the daily sudoku puzzle from http://www.sudoku.org.uk/ Fetches the daily sudoku puzzle from http://www.sudoku.org.uk/ or one of their archive from the previous 31 days. fetchsudokuuk(day) day Optional character string specifying the day of the puzzle to download. This is in European date format dd/mm/yyyy and needs to represent a date within the last 31 days. Note A 9x9 matrix representing a sudoku puzzle (blank squares have value 0). See the website for copyright information. Don t submit your solution for the prize contest if you used solvesudoku or playsudoku with solve=true. This function requires a working internet connection. Greg Snow <greg.snow@intermountainmail.org> References See Also http://www.sudoku.org.uk/ solvesudoku, playsudoku, generatesudoku Examples ## Not run: #todays puzzle puz <- fetchsudokuuk() # puzzle from 25 Jan 2006 (if still available) puza <- fetchsudokuuk( 25/01/2006 )

generatesudoku 3 playsudoku(puza) ## End(Not run) generatesudoku Randomly Generate a Sudoku Puzzle Grid Creates a 9x9 Sudoku grid suitable for use by playsudoku. generatesudoku(nblank=50, print.it=false) Nblank print.it Number of cells to blank out Logical. If true, print result to screen. Details The basic algorithm is to start with a primordial Sudoku grid, swap around some rows and columns, then blank out some cells. A matrix, representing a 9x9 Sudoku grid. Curt Seeliger <<Seeliger.Curt@epamail.epa.gov>>, Henrik Bengtsson <<hb@maths.lth.se>>, and David Brahm <<brahm@alum.mit.edu>> References http://sudoku.com/ Examples generatesudoku(print.it=true)

4 playsudoku hintsudoku Give a Hint for a Sudoku Cell Generates a text string containing a hint for cell (i,j) of Sudoku grid z. hintsudoku(z, i, j) z i j A 9x9 numeric matrix Row index Column index A character string, suitable for cat. Greg Snow <greg.snow@intermountainmail.org> and David E. Brahm <<brahm@alum.mit.edu>> playsudoku Interactively play a game of Sudoku 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,...)

playsudoku 5 z Details hist.len solve display hscale vscale 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 readsudoku), or NULL to generate a puzzle randomly. Integer representing the number of history steps to remember (number of undo s possible). Logical indicating if the solution should be computed (used for checking current answer or cheating). Type of display. The default guess uses a windows graphics device if getoption( device )== windows, otherwise it uses tk (requiring the tkrplot package). Passed to tkrplot Passed to tkrplot... passed to generatesudoku 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). Note 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>>

6 printsudoku See Also solvesudoku Examples ## Not run: puz1 <- playsudoku(0) sol1 <- playsudoku(puz1) puz2 <- edit(matrix(0,9,9)) sol2 <- playsudoku(puz2) playsudoku() playsudoku(fetchsudokuuk()) # Use as an editor to create a puzzle, then quit # now play the puzzle # Or use this editor # now play the puzzle # Play a randomly generated game # Play today s game ## End(Not run) printsudoku Print a Sudoku Grid to the Terminal. Prints a Sudoku grid (a 9x9 matrix) to the terminal. printsudoku(z) z A 9x9 numeric matrix, with 0 representing a blank cell. None; used for side effect. David E. Brahm <<brahm@alum.mit.edu>>

readsudoku 7 readsudoku Read a File Containing a Sudoku Grid Reads a file containing a Sudoku grid (a 9x9 matrix). readsudoku(fn, map) fn map A filename. 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. 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. A numeric matrix (usually 9x9). David E. Brahm <<brahm@alum.mit.edu>> Examples z <- readsudoku(system.file("puz1.txt", package="sudoku"))

8 solvesudoku solvesudoku Solve a Sudoku Puzzle Solves a Sudoku Puzzle. solvesudoku(z, verbose=false, map=c(1:9,letters), level=0, print.it=true) z verbose map level print.it A filename (passed to readsudoku), or a numeric matrix. If TRUE, report on progress. 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. Recursion level (should not be set by user). Logical: print the solution? Details A Sudoku puzzle consists of an NxN grid, where N is a perfect square (usually N=9). The grid is subdivided into N [sqrt(n) x sqrt(n)] boxes. You must fill in the missing values so that each row, each column, and each box contains the integers 1:N exactly once. The algorithm uses an NxNxN array of logicals, representing the NxN cells and the N possible elements. For example, if a[1,2,3]=true, then z[1,2] is known to be 3. If a[1,2,4]=false, then z[1,2] is known not to be 4. The basic rules of Sudoku are used to fill in FALSE s, then elimination is used to find the TRUE s. If that approach runs out of steam, a guess is made and the program recurses to find either a solution or an inconsistency. No attempt is made to prove a solution s uniqueness. Invisibly returns the solved (numerical) matrix, and prints the character version. David E. Brahm <<brahm@alum.mit.edu>> References Example "puz1" comes from http://sudoku.com/.

writesudoku 9 Examples ## Not run: solvesudoku(system.file("puz1.txt",package="sudoku"), verbose=true) ## End(Not run) writesudoku Write a Sudoku Grid to a File Writes a Sudoku grid (a matrix) to a file. writesudoku(z, fn) z fn A Sudoku grid. A filename. None; used for its side effect. David E. Brahm <<brahm@alum.mit.edu>> See Also readsudoku

Index Topic array generatesudoku, 3 hintsudoku, 4 printsudoku, 6 readsudoku, 7 solvesudoku, 8 writesudoku, 9 Topic dynamic playsudoku, 4 Topic misc fetchsudokuuk, 2 fetchsudokuuk, 2 generatesudoku, 2, 3, 5 hintsudoku, 4 playsudoku, 2, 3, 4 printsudoku, 6 readsudoku, 5, 7, 8, 9 solvesudoku, 2, 6, 8 writesudoku, 9 10