A JIGSAW SUDOKU GENERATOR AND SOLVER

Similar documents
arxiv: v2 [math.ho] 23 Aug 2018

Techniques for Generating Sudoku Instances

The Mathematics Behind Sudoku Laura Olliverrie Based off research by Bertram Felgenhauer, Ed Russel and Frazer Jarvis. Abstract

Cracking the Sudoku: A Deterministic Approach

SUDOKU X. Samples Document. by Andrew Stuart. Moderate

Kenken For Teachers. Tom Davis January 8, Abstract

You ve seen them played in coffee shops, on planes, and

Chameleon Coins arxiv: v1 [math.ho] 23 Dec 2015

The mathematics of Septoku

Some results on Su Doku

Latin Squares for Elementary and Middle Grades

Taking Sudoku Seriously

A Group-theoretic Approach to Human Solving Strategies in Sudoku

We hope you enjoy the set. Good luck for the Indian Puzzle Championship! 3 A B C 4 H D 5 G F E 7 A B 8 H 9 G F

37 Game Theory. Bebe b1 b2 b3. a Abe a a A Two-Person Zero-Sum Game

of Nebraska - Lincoln

1 Introduction. 2 An Easy Start. KenKen. Charlotte Teachers Institute, 2015

Zsombor Sárosdi THE MATHEMATICS OF SUDOKU

Comparing Methods for Solving Kuromasu Puzzles

Welcome to the Sudoku and Kakuro Help File.

Sudoku an alternative history

SudokuSplashZone. Overview 3

Take Control of Sudoku

Universiteit Leiden Opleiding Informatica

Slitherlink. Supervisor: David Rydeheard. Date: 06/05/10. The University of Manchester. School of Computer Science. B.Sc.(Hons) Computer Science

Yet Another Organized Move towards Solving Sudoku Puzzle

An Exploration of the Minimum Clue Sudoku Problem

The Problem. Tom Davis December 19, 2016

New designs from Africa

Lower Bounds for the Number of Bends in Three-Dimensional Orthogonal Graph Drawings

EXPLAINING THE SHAPE OF RSK

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

A Memory-Efficient Method for Fast Computation of Short 15-Puzzle Solutions

Tilings with T and Skew Tetrominoes

A GRAPH THEORETICAL APPROACH TO SOLVING SCRAMBLE SQUARES PUZZLES. 1. Introduction

Sudoku Solver Manual. Version June 2017

Cryptic Crosswords for Bright Sparks

Grade 7/8 Math Circles. Visual Group Theory

arxiv: v1 [cs.cc] 21 Jun 2017

Rotational Puzzles on Graphs

Launchpad Maths. Arithmetic II

Investigation of Algorithmic Solutions of Sudoku Puzzles

Asymptotic Results for the Queen Packing Problem

Lumines Strategies. Greg Aloupis, Jean Cardinal, Sébastien Collette, and Stefan Langerman

How to Make the Perfect Fireworks Display: Two Strategies for Hanabi

Grade 7/8 Math Circles. Visual Group Theory

On the Combination of Constraint Programming and Stochastic Search: The Sudoku Case

Chapter 1. The alternating groups. 1.1 Introduction. 1.2 Permutations

Applications of Advanced Mathematics (C4) Paper B: Comprehension WEDNESDAY 21 MAY 2008 Time:Upto1hour

Dyck paths, standard Young tableaux, and pattern avoiding permutations

10 GRAPHING LINEAR EQUATIONS

Applications of Advanced Mathematics (C4) Paper B: Comprehension INSERT WEDNESDAY 21 MAY 2008 Time:Upto1hour

ON OPTIMAL PLAY IN THE GAME OF HEX. Garikai Campbell 1 Department of Mathematics and Statistics, Swarthmore College, Swarthmore, PA 19081, USA

Mathematical Proof of Four-Color Theorem. By Liu Ran. After examining a wide variety of different planar graphs, one discovers

Monte Carlo based battleship agent

Solving Sudoku Using Artificial Intelligence

The patterns considered here are black and white and represented by a rectangular grid of cells. Here is a typical pattern: [Redundant]

1. Non-Adaptive Weighing

Probability Interactives from Spire Maths A Spire Maths Activity

EXPLORING TIC-TAC-TOE VARIANTS

Tile Number and Space-Efficient Knot Mosaics

Solving and Analyzing Sudokus with Cultural Algorithms 5/30/2008. Timo Mantere & Janne Koljonen

Algorithmique appliquée Projet UNO

THE 15-PUZZLE (AND RUBIK S CUBE)

ON 4-DIMENSIONAL CUBE AND SUDOKU

SOLITAIRE CLOBBER AS AN OPTIMIZATION PROBLEM ON WORDS

MAS336 Computational Problem Solving. Problem 3: Eight Queens

Games of Skill ANSWERS Lesson 1 of 9, work in pairs

Spring 06 Assignment 2: Constraint Satisfaction Problems

Introduction to Counting and Probability

AL-JABAR. Concepts. A Mathematical Game of Strategy. Robert P. Schneider and Cyrus Hettle University of Kentucky

Section Marks Agents / 8. Search / 10. Games / 13. Logic / 15. Total / 46

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Optimal Yahtzee A COMPARISON BETWEEN DIFFERENT ALGORITHMS FOR PLAYING YAHTZEE DANIEL JENDEBERG, LOUISE WIKSTÉN STOCKHOLM, SWEDEN 2015

SET THEORY AND VENN DIAGRAMS

Grade 6 Math Circles February 15, 2012 Math Puzzles

isudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris

Olympiad Combinatorics. Pranav A. Sriram

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four 1

Grade 6 Math Circles March 7/8, Magic and Latin Squares

Modeling a Rubik s Cube in 3D

Overview. Initial Screen

Published in India by. MRP: Rs Copyright: Takshzila Education Services

In Response to Peg Jumping for Fun and Profit

puzzles may not be published without written authorization

STRATEGY AND COMPLEXITY OF THE GAME OF SQUARES

CMPT 310 Assignment 1

Non-overlapping permutation patterns

arxiv: v1 [math.gt] 21 Mar 2018

An improved strategy for solving Sudoku by sparse optimization methods

Universiteit Leiden Opleiding Informatica

Graph Theory: The Four Color Theorem

Tribute to Martin Gardner: Combinatorial Card Problems

Problem Set 10 2 E = 3 F

Sudoku Solvers. A Different Approach. DD143X Degree Project in Computer Science, First Level CSC KTH. Supervisor: Michael Minock

Spring 06 Assignment 2: Constraint Satisfaction Problems

Grade 7/8 Math Circles. Mathematical Puzzles

arxiv:cs/ v2 [cs.cc] 27 Jul 2001

Slicing a Puzzle and Finding the Hidden Pieces

#A13 INTEGERS 15 (2015) THE LOCATION OF THE FIRST ASCENT IN A 123-AVOIDING PERMUTATION

Transcription:

A JIGSAW SUDOKU GENERATOR AND SOLVER Christopher Stephens. 2 nd May 2007. Supervisor: Dr. Andrea Schalk This report discusses the game of Jigsaw Sudoku. The main aim of the project is to create a program which can generate and solve Jigsaw Sudoku. Algorithms are discussed dealing with the creation of Jigsaw Sudoku puzzles. Strategies for solution of Sudoku and Jigsaw Sudoku are defined and a method of linking these strategies is dealt with. A discourse of the mathematics associated with Jigsaw Sudoku is provided, including sections on the Four-Colour Theorem and setting of hints. An analysis of the effects of the number of hints on solvability is carried out. Evaluations of the success of the project are made and extensions are indicated. A conclusion and summary of the project as a whole is provided. 1

ACKNOWLEDGEMENTS I would like to thank my supervisor and tutor Andrea Schalk for the support she has given me during my three years at university and her valuable input into this project. I would like to thank my girlfriend, proof reader and thesaurus Lesley Campbell for managing to resist strangling me, regardless of requests for assistance at 3am. 2

In memory of my dad, Trevor. Regrettably he will not be able to attend my graduation. 3

CONTENTS Figures... 6 Excursuses...7 Précis...8 1: Background...10 1.1: Sudoku...10 1.2: Jigsaw Sudoku... 11 1.3: Mathematics of Sudoku...12 1.4: The Strategies of Sudoku... 12 2: Aims and Challenges...13 2.1: The Project...13 2.2: Why?... 13 2.3: The Challenges... 14 2.4: Extras...14 2.5: Thoughts...14 3: The Creation... 16 3.1: Shuffling... 16 3.2: Setting the Hints...19 3.3: Counting Solutions... 20 4: The Solution...22 4.1: Levels of Difficulty...22 4.2: Narrowing the Possibilities... 22 4.3: In the Game...23 4.4: Novice Sudoku Strategies... 23 4.4.1: Only-Possible... 24 4.4.2: Singles... 24 4.4.3: Conjugate Pairs...24 4.5: Selected Harder Strategies... 25 4.5.1: Pointing Couplets...25 4.5.2: X-Wings...26 4.6: Jigsaw Sudoku Specific Strategies... 27 4.6.1: Little Law of Leftovers...27 4.6.2: Big Law of Leftovers... 28 4

5: Usability... 30 5.1: The Game... 30 5.1.1: Saving and Loading... 30 5.1.2: Clues...30 5.1.3: User-Inputted Grids...31 5.2: Four-Colouring...31 6: Analysis... 33 6.1: Hints vs. Solvability...33 6.2: The 3x3 Experiment... 34 6.3: The 4x4 Experiment... 35 6.4: N 1 Hints...36 6.5: N 2 Hints...38 6.6: Permutations of Non-Unique Grids... 38 7: Evaluation and Extensions... 40 7.1: Generating Large Grids...40 7.2: Further Strategies... 40 7.3: Choice of Difficulty... 41 7.4: Superfluity...41 8: The Conclusion...43 8.1: Achievements... 43 8.2: Issues and Revisions... 44 8.3: Summary... 44 Reading List... 45 Appendix A: Results of Experiments...47 5

FIGURES Figure 1.1: A Sudoku Puzzle... 11 Figure 1.2: A Jigsaw Sudoku Puzzle... 11 Figure 3.1: Pieces Sharing a Single Edge... 17 Figure 3.2: Shuffling a 4x4 Grid... 18 Figure 4.1: The possibilities... 23 Figure 4.2: A Sketched X-Wing... 26 Figure 5.1: A Comparison of a Graduated vs. a Four-Coloured Grid...31 Figure 6.1: Number of Hints Placed vs. Unique Solutions Generated (3x3)... 35 Figure 6.2: Number of Hints Placed vs. Unique Solutions Generated (4x4)... 36 Figure 6.3: Permutations of a and b in a Grid of Size 3... 39 Figure 7.1: Superfluous Hints... 42 6

EXCURSUSES Excursus 3.1: The Shuffling Algorithm...17 Excursus 3.2: Checking Completeness of a Given Piece... 18 Excursus 3.3: Arbitrary Numbers...19 Excursus 3.4: To Place the Hints... 20 Excursus 3.4: Counting Solutions An Example... 21 Excursus 4.1: Conjugate Pairs An Example... 24 Excursus 4.2: Pointing Couplets... 25 Excursus 4.3: X-Wings An Example...27 Excursus 4.4: The Little Law of Leftovers... 28 Excursus 4.5: The Big Law of Leftovers...29 Excursus 5.1: A Proof of the Four-Colour Theorem... 32 Excursus 6.3: Proof of N 1 Hints Leading to a Unique Solution...37 Excursus 6.4: Proof that N 2 Hints will not Lead to a Unique Solution...38 7

PRÉCIS 1: BACKGROUND This section introduces the reader to the games of Sudoku and Jigsaw Sudoku. The rules of the games are explained and uniqueness is discussed. A range of mathematical facts about Sudoku are imparted and the idea of using strategies to solve a grid is presented. 2: AIMS Here, a more specific discussion of the project shall be carried out. The main aim of the project is announced, as well as a consideration of the merits of project. Challenges identified within the project are also described. 3: THE CREATION This chapter addresses the main challenges associated with the creation of a playable Jigsaw Sudoku puzzle. The problem of creating a grid of randomly shaped pieces is considered, followed by the question of setting the hints. 4: THE SOLUTION Here I shall explain a selection of the strategies used in the report.to begin, there shall be an explanation of the difficulty of a strategy and the term possibility. A selection of strategies will then be outlined. 5: USABILITY Usability covers the extra bits of implementation which makes the game usable and playable. Firstly, the functionality of the game itself is discussed. Following this is a discourse of the Four-Colour Threorem, which I have used in the game. 6: ANALYSIS Here, an investigation is performed into the dependence of the uniqueness on the number of given hints. Following this a discussion of the mathematics associated with setting the 8

hints is provided. Proofs and further original thoughts are outlined. 7: EVALUATION AND EXTENSIONS This, the penultimate chapter, provides an insight into problems faced within the project. It also describes a selection of extensions which have been thought about but not implemented. 8: CONCLUSION This final chapter sums-up the project as a whole. An account of the achievements is given, along with a selection of notable issues. Finally, the project as a whole is summarised and concluding thoughts given. 9

1: BACKGROUND This section introduces the reader to the games of Sudoku and Jigsaw Sudoku. The rules of the games are explained and uniqueness is discussed. Following this, there is a look into some mathematical facts about Sudoku. These facts include the number of Sudoku grids and the number of hints needed to create a 9x9 game. Finally the question of solving a puzzle is addressed and the idea of the strategies used in the game is approached. 1.1: SUDOKU The Oxford English Dictionary defines Sudoku to be: A type of logic puzzle, the object of which is to fill a grid of nine squares by nine squares (subdivided into nine regions of three by three squares) with the numbers one to nine, in such a way that every number appears only once in each horizontal line, vertical line, and three-by-three subdivision. 1 To expand upon the OED: Sudoku is a popular single player pen and paper puzzle. The aim is to complete a partially filled 9x9 grid with numbers whilst obeying the law of the game: namely that no numeral should be duplicated in any row, column or 3x3 sub-grid. Initially the player is given a partially complete grid. The numbers within this grid are referred to as the hints. With these as a starting point the player must set out to fill in the remainder of the puzzle. A Sudoku puzzle is considered well formed if there is a unique solution. That is to say, given an initial set of hints, there exists just one possible legal way of completing the puzzle. A unique solution for a Sudoku puzzle is obviously desirable. It removes ambiguity and, in the simplest example, it makes it possible for a newspaper to print an answer. 1 'Sudoku, n.' OED Online. December 2006. Oxford University Press. <http://dictionary.oed.com/cgi/entry/50291646> (28 th March 2007). 10

Figure 1.1: A Sudoku Puzzle. 1.2: JIGSAW SUDOKU Jigsaw Sudoku is a variation of Sudoku in which the 3x3 sub-grids are replaced by irregular jigsaw pieces. Jigsaw Sudoku is know by many pseudonyms: Squiggly Sudoku, Du-sum-oh, Nononimo, Geometric Sudoku to name a few. Figure 1.2: A Jigsaw Sudoku Puzzle. Often published Jigsaw Sudoku puzzles have some degree of symmetry. Note that Figure 1.2 is symmetrical about 180. 11

1.3: MATHEMATICS OF SUDOKU The set of all completed 9x9 Sudoku puzzles is a subset of a much larger set of 9x9 Latin Squares, 2 in which there are no repeated digits in each row and column. Latin Squares were introduced by Leonhard Euler in 1783. 3 A count of all complete 9x9 Sudoku grids was found to be 6,670,903,752,021,072,936,960, approximately 0.00012% of the total number of Latin Squares, in 2005. 4 Of these 5472730538 are said to be essentially unique when symmetries are taken into account. 5 The smallest number of hints found to generate a uniquely solvable 9x9 Sudoku is 17; 6 this has not been proven. The smallest number of hints needed to generate a uniquely solvable 9x9 Jigsaw Sudoku has been proven to be as low as 8. 7 This is discussed in 6.4. 1.4: THE STRATEGIES OF SUDOKU Almost all Sudoku puzzles are solvable using logic alone. In most published Sudoku puzzles there will be a set of methods that enable the player to solve the game without requiring a guess. A strategy is a method that reduces the problem faced by the player when completing a given Sudoku puzzle. An enormous number of strategies, based on logical deductions, have been created. 8 There are many well documented strategies available to aid a player whilst solving a standard Sudoku puzzle. The same cannot be said for Jigsaw Sudoku; in researching the game I have only managed to find two documented Jigsaw Sudoku specific strategies. 9 The strategies of Sudoku will be discussed further in Section 4. 2 Richard Turner. Sudoku Tea Talk. <http://www.gatsby.ucl.ac.uk/~turner/sudoku/sudoku.html> (7 th April 2007). 3 Cut the Knot. Latin Squares. <http://www.cut-the-knot.org/arithmetic/latin.shtml> (7 th April 2007). 4 B Felgenhauer and F Jarvis. Sudoku Enumeration Problems. <http://www.afjarvis.staff.shef.ac.uk/sudoku/> (29 th March 2007). 5 E Russell and F Jarvis. Sudoku Enumeration Problems. <http://www.afjarvis.staff.shef.ac.uk/sudoku/> (29 th March 2007). 6 Gordon Royle. Minimum Sudoku. <http://people.csse.uwa.edu.au/gordon/sudokumin.php> (3 rd April 2007). 7 Bob Harris. Du-Sum-Oh Puzzles. <http://www.bumblebeagle.org/dusumoh/proof/index.html> (2 nd April 2007). 8 Andrew Stuart. Sudoku Solver by Andrew Stuart. <http://www.scanraid.com/sudoku.htm> (2 nd April 2007). 9 Bob Harris. Du-Sum-Oh Puzzles. <http://www.bumblebeagle.org/dusumoh/8x8/tutorial/index.html> (2 nd April 2007). 12

2: AIMS AND CHALLENGES The previous chapter gave an overview of the game of Sudoku. Here, a more specific discussion of the project shall be carried out. Firstly, the principal all-encompassing aim is announced. Following this is a brief discourse about the merits of choosing the project. This compares Sudoku and Jigsaw Sudoku puzzles. In addition, it contrasts the volume of prior research into each type of puzzle. Next, the primary challenges identified in the project are noted and described. The secondary objectives are also covered. Finally, a round up of the original expectations of the project is included. 2.1: THE PROJECT It is my aim to create a computer program capable of generating and solving Jigsaw Sudoku puzzles. 2.2: WHY? The setting and solving of traditional Sudoku has been substantially documented, but Jigsaw Sudoku is less well known. In recent months Jigsaw Sudoku has become more prominent. Whilst researching this project I was unable to find a Jigsaw Sudoku solver on-line. Today there are a handful of Jigsaw Sudoku solvers, 10 most of which are extensions to traditional Sudoku programs. Of the solvers I have found on-line there are none that can set randomly generated games. They shun generation in favour of user-inputted grids or a selection of ready made puzzles. In this aspect, I believe that my work in generating Jigsaw Sudoku games is wholly original. 10 These include: Funahashi Study Private School, Japan. Zigzag Sudoku Solver / Irregular Number Place / Geometric <http://homepage3.nifty.com/funahashi/game/game655eng.html> (10 th April 2007). Andrew Stuart. Jigsaw Solver by Andrew Stuart. <http://www.scanraid.com/jigsaw.htm> (10 th April 2007). 13

2.3: THE CHALLENGES Initial research identified three major challenges: 1. Creating a grid of jigsaw pieces. 2. Placing the hints to create a uniquely solvable grid. 3. Solving the game using a bank of strategies. Firstly a grid of jigsaw pieces is created. This is then filled with randomly shaped pieces of the correct size. Following the setting of the shape of the puzzle, the hints are placed. It is important that the game is solvable by logic alone. The third challenge is to create an artificial intelligence capable of solving a Sudoku puzzle. This would be very easy to implement using brute force computing, but this is not desirable. The final program must be able to explain to the user what is happening at each step in the solution process. 2.4: EXTRAS In addition to the above challenges it is necessary to design a program that is usable. For example: it would be undesirable to have a complex program that is text-based. To this end, there are many further features which need to be created. These features include, but are not limited to: 1. Designing an intuitive user interface. 2. Implementing useful functions (e.g. saving and loading). 3. Providing assistance when a player is stuck. 2.5: THOUGHTS Due to the extensive scope of Sudoku, there are other possible considerations to the challenges I have presented here. Because of the constraints on the project I have to be realistically selective about what I will achieve. I feel the aims outlined above are a good and varied selection suitable for a third year project. Each of these aims demonstrates a 14

different set of skills. During the implementation it will be important to make careful decisions and to prioritise certain aspects above others. These decisions are crucial to the success of the project. As a joint honours computer science and mathematics student I would like to draw upon my mathematical background. To this end, I shall research proofs and aim to give an analysis based around the game of Jigsaw Sudoku. 15

3: THE CREATION Two of the three significant challenges identified in the previous section are concerned with the creation of a playable Jigsaw Sudoku puzzle. This chapter addresses these two aims in detail. The problem of creating a grid of jigsaw pieces is investigated. After the initial thoughts are addressed, an elegant solution is provided to solve the problem. 3.2 looks at setting the hints to create a uniquely solvable game. Here, the problem of counting solutions is uncovered. Lastly, thoughts are turned to resolving this problem. 3.1: SHUFFLING The initial step in the process of creating a Jigsaw Sudoku puzzle is producing the jigsaw. My first thought was to generate random shaped pieces of the required size and then try to fit them into the board. This turned out to be much harder than I imagined. Anyone who has played the game of Tetris will tell you how difficult space-filling problems can be. Another example of a space filling problem is the game of Pentominoes. In Pentominoes, shapes made up of five squares are attempted to be inserted into a grid. Entire computer science projects have been made to play Pentominoes. 11 To create a standard Jigsaw Sudoku puzzle, pieces of size nine must be considered. Hence the idea of space-filling was discounted. An elegant and simple solution was needed. I formulated the idea of shuffling the board. Given a grid of regularly shaped pieces (i.e. a standard Sudoku board), I found it possible to swap squares around to create a shuffled grid. 11 For Example: Robert Simms. Pentominoes. <http://www.math.clemson.edu/~simms/java/pentominoes/> (23 rd April 2007). 16

THE SHUFFLING ALGORITHM for(required number of shuffles) { Select two random squares; Swap these squares; if(both pieces are still whole ) { Re-colour grid; } } else { Swap squares back; } Excursus 3.1: The Shuffling Algorithm. The original attempt at creating a shuffling algorithm intended to swap squares from adjacent pieces. Finding a pair of adjacent pieces proved to be a difficult task in itself. In addition, there is no guarantee that swapping squares from neighbouring pieces will leave the two pieces complete (See Figure 3.1). Obviously pieces which are incomplete are undesirable and lead to a very confusing situation for the player. Consider two pieces sharing a single edge, as shown in the diagram below. Evidently, swapping any two squares within these pieces will leave neither piece whole. Figure 3.1: Pieces Sharing a Single Edge. After a good deal of thought, the need to find adjacent pieces was deemed unnecessary. It would be sufficient to choose random pieces and random squares, then to check whether the chosen pieces would remain whole upon swapping. 17

Figure 3.2: Shuffling a 4x4 Grid. To implement the shuffling algorithm it was necessary to create a method of checking that a piece is whole. To achieve this, start with a square within the jigsaw piece, then recursively check the surrounding squares that lie within the piece. If every square in the jigsaw piece can be counted then it is whole. CHECKING COMPLETENESS OF A GIVEN PIECE Starting with any square within the piece. if (the given square lies within the selected piece and this square has not yet been visited) { Note that this square has now been visited; Recursively call this method with the 4 surrounding squares; } if (all squares within the selected piece have been visited) { The piece is whole and this can be returned; } Excursus 3.2: Checking Completeness of a Given Piece. 18

3.2: SETTING THE HINTS The next step in creating a puzzle is to generate a set of hints which lead to a uniquely solvable game. The hints, as described in 1.1, are the initial numbers placed on the grid. To achieve numbers are added to the grid at random (obeying the laws of the game) and the number of possible solutions is counted. In the first instance, the program counted solutions after placing each hint. If the count was zero then the program removed the last hint placed. Likewise, if the count was greater than one then further hints were added. Where neither of these cases were true, the count was equal to one, hence the game must have been uniquely solvable and ready to play. This was found to be slow and impractical. Since it is the case that the number of hints has no measurable effect on the difficulty 12 (further explained in 4.5), I decided that placing an arbitrary number of hints and then counting solutions would be a better method. ARBITRARY NUMBERS In deciding on an arbitrary number I considered formulas which give a reasonable outcome for every possible size of grid. In my experience most published 9x9 Sudoku grids have roughly 25 hints, I based my decision on this and settled on the formula: N 2 3 2 (Where N is the size of the grid) This gives the results below: N 3 4 5 6 7 8 9 Hints 2 4 7 11 15 20 26 Excursus 3.3: Arbitrary Numbers. Once an arbitrary number of hints have been placed, the program counts the number of solutions. If the solution is not unique, the grid will be cleared and the hints will be replaced. Given that counting solutions is considerably more complex than placing the hints, I decided that this would be preferable to the alternative of counting solutions after 12 Wikipedia. Sudoku Wikipedia, the free encyclopedia. <http://en.wikipedia.org/wiki/sudoku#difficulty_ratings> (14 th April 2007). 19

placing each hint. TO PLACE THE HINTS For(Required number of hints) { Choose random number and random square; If(number and square chosen obey laws) { Place number in square; } } If(Board not solvable) { Start this process again. } Excursus 3.4: To Place the Hints. 3.3: COUNTING SOLUTIONS Counting solutions is a variation on the solving method. A set of possibilities for each square is generated. A possibility is a number that could be placed in its square such that the grid remains solvable. The program must count all possible legal permutations of these possibilities. To begin, it looks at the first square with a single possibility, and inserts this into the grid. At this stage the set of possibilities for every square is re-generated. It is not always the case that there exists a square with a single possibility; all squares may contain multiple possibilities. In this instance, a choice would be made from the first square with the smallest number of possibilities. If this choice was found to lead to a dead end then it would be removed, and another possibility from the square put in its place. The aim of this process is to be able to fill in every square on the grid from their respective possibilities. For each combination where every square is filled the count is incremented. The following example demonstrates this in more detail. 20

COUNTING SOLUTIONS AN EXAMPLE In the case shown, in the top-left square (1,1) the possibles are 1 and 2. If 1 is chosen then a 4 must be placed below it (1,2). This leads to (1,3) and (1,4) both having a 3 as a single possibility. Since (1,3) and (1,4) are in the same column this would be contradictory. Hence placing a 1 in (1,1) leads to the grid being unsolvable. On the other hand, if a 2 is placed at (1,1), then at every subsequent step there exists a square with only one possible and the game is uniquely solvable (the solution count equals one). This could be represented as a game tree: 13 (1,1) = 1 (1,1) = 2 (1,2) = 2 (1,3) = 1 (1,3) = 3 STUCK! (4,4) = 2 SOLUTION! This is a small simple case, larger cases lead to much more complex trees. Since there is just one branch that leads to a solution this grid is uniquely solvable. Excursus 3.5: Counting Solutions An Example. 13 Mikhael Shor. Game Tree Game Theory.net <http://www.gametheory.net/dictionary/gametree.html> (29 th April 2007). 21

4: THE SOLUTION There are many different strategies of varying difficulty used to solve Sudoku. Here I shall explain a selection of the strategies used in the program. To begin, there shall be an explanation of what is meant by the difficulty of a strategy. Following this, the idea of possibilities will be explored further. An understanding of possibilities is required to link the strategies together. It is then considered how the strategies are applied in the game itself. The selection is limited by constraints on the report. There are a huge number of known strategies for solving Sudoku; it is not feasible to explore or implement all of them in the available time. 4.1: LEVELS OF DIFFICULTY Many people assume that the level of difficulty is dependent on the given number of hints. This is not necessarily the case; two Sudoku puzzles containing the same number of hints could be hugely different in their complexity. The level of difficulty is dependant on the strategies needed to solve the given Sudoku puzzle. A puzzle that is solvable using just elementary strategies would be regarded as straightforward. Due to the qualitative nature of the problem, it is not possible to grade a strategy's difficulty exactly. Saying that, I have broadly categorised a selection of strategies as easy, intermediate or hard. 4.2: NARROWING THE POSSIBILITIES Returning to the Oxford English Dictionary the object of the game is to fill a grid... with the numbers one to nine, in such a way that every number appears only once in each horizontal line, vertical line, and three-by-three subdivision. 14 Given this and the original set of hints, the possibilities can be generated for every square. 14 "Sudoku, n." OED Online. December 2006. Oxford University Press. <http://dictionary.oed.com/cgi/entry/50291646>. (28 th March 2007). 22

The possibilities are the set of numbers such that when one of the set is placed in its square the grid remains valid and legal. These are generated by searching through the row, column and piece occupied by the square, and discarding any numbers which appear. Figure 4.1: The possibilities. 4.3: IN THE GAME The Jigsaw Sudoku solver reduces the possibilities by finding numbers within the grid that it can apply a strategy to. Like a human player it will first consider the easiest strategy known to it. If this provides no assistance it shall attempt to use further strategies. Once a strategy is identified that can help in solving the grid, it is implemented and the process starts again on the simplified grid with the easiest strategy. The grand aim of the bank of strategies is to reduce the possibilities in every square to a single number. Whence they are vacuously solved. 4.4: NOVICE SUDOKU STRATEGIES The novice strategies provided here should be sufficient to solve any published Sudoku puzzle classed as easy or straightforward. Many very easy puzzles are solvable using just the only-possible strategy. 23

4.4.1: ONLY-POSSIBLE The only-possible is the most straightforward strategy. If there exists only one possibility in a square then obviously the square is solved, and the possibility can be placed. Identifying and placing these possibilities shall be known as the only-possible strategy. In Figure 5.1 there is an only-possible at square (1,2), hence a 4 must be placed here. 4.4.2: SINGLES A single is almost as straightforward as an only-possible. If a number occurs just once within the possibilities of a row, column or piece then it is a single. All other numbers can be removed from the possibilities in the square where this single occurs. In Figure 5.1 there is a single 2 in the first column at (1,1). Hence the 4 can be removed and 2 is left as an only-possible. 4.4.3: CONJUGATE PAIRS Whilst conjugate pairs are more complex than the two strategies above, I believe that they should be here as the basis for a variety of other strategies. A conjugate pair is a set of two possibilities that exist at just two squares in a given row, column or piece. The two squares containing the conjugate pair are the only potential locations for the numbers within it. Thus the possibilities of these two squares can be reduced to the numbers within the conjugate pair. CONJUGATE PAIRS AN EXAMPLE To the left is an example of a conjugate pair. Note that the numbers 1 and 2 appear in just the two highlighted squares. This fact forces both of the highlighted squares to be a 1 or 2. Hence the 4 and 8 can be deleted from these two squares. Note: This piece could easily be solved using other strategies. Excursus 4.1: Conjugate Pairs An Example. 24

This strategy will reduce the possibilities in two squares to two, simplifying the puzzle and enabling other strategies to be used. The same principle can be extended to triples and quads (or further if required). 4.5: SELECTED HARDER STRATEGIES The novice strategies discussed in 4.4 might be enough to solve a Sudoku puzzle described as easy. The following strategies are of assistance when solving a harder puzzle. Again, the strategies explained here are just a small selection of all the known strategies. 4.5.1: POINTING COUPLETS Consider a partially filled piece within a Sudoku puzzle. If there exists a couplet (or triplet or quad) of possibilities within the intersection of the piece and a single row or column then the pointing couplets strategy can be used. Consider the couplet again. Since the possibilities say that they cannot lie elsewhere in the given piece, they can be removed from elsewhere in the given row or column. This strategy is far easier to explain with an example: POINTING COUPLETS Consider the couplet of 4s which are highlighted in the partial grid above. This couplet contains the only occurrences of 4 in the centre piece. Now, it must be the case that the 4s in the centre piece must lie on the row highlighted. Hence all other occurrences of 4 in the row can be discarded. Excursus 4.2: Pointing Couplets 25

4.5.2: X-WINGS The X-wing strategy is more complicated again. The strategy looks at couplets of occurrences in rows and columns. To improve the clarity of this explanation I shall refer to just the row variant. The column variant is exactly the same, simply substitute the word row for column, and vice versa. The X-wing strategy is as follows: If a couplet of numbers exists in the same column of two different rows, and the numbers exist at no other points in these rows, then the occurrences of the numbers in the columns can be eliminated. Figure 4.2: A Sketched X-Wing. Consider the sketched grid above. Imagine there are two couplets of numbers in the blue squares, and that these numbers occur nowhere else in the two selected rows. Then all other occurrences of the numbers in the selected columns can be deleted. The term X-wing is used due to the linking between the four squares. In fact the squares joined by a single line in the diagram must contain the same number. Again, the X-wing strategy is a great deal easier to explain given an example: 26

X-WINGS AN EXAMPLE Regard the two grids below. Note that a matching couplet of 6s occurs in the first and fourth rows, at (1,1), (1,6), (4,1) and (4,6). There are no other 6s in these rows. These couplets form an X-Wing, and thus the 6s at (1,5), (1,6) and (6,5) can be removed. Excursus 4.3: X-Wings An Example. 4.6: JIGSAW SUDOKU SPECIFIC STRATEGIES The earlier strategies in this chapter can be applied to all Sudoku and Jigsaw Sudoku puzzles. This section describes two Jigsaw Sudoku specific strategies. Most Jigsaw Sudoku puzzles could be solved with just adaptations of standard strategies. The Jigsaw Sudoku specific strategies are useful because once they have been learnt, they are easy to spot. 4.6.1: LITTLE LAW OF LEFTOVERS The Little Law of Leftovers strategy can be applied to a Jigsaw Sudoku puzzle when rows, columns or pieces have squares in common. The strategy states that given two intersecting rows, columns or pieces then the subsets of 27

these two sets lying outside the intersection must be equal. The sets lying outside the intersection are known as the leftovers. More mathematically, given two sets A and B: A A B = B A B This is better explained below: THE LITTLE LAW OF LEFTOVERS Consider the grid below, specifically the intersection (marked in grey) between the lower-right piece and the final column. 3 2 4 1 5 6 3 In this case, five out of six numbers in the column and the piece respectively lie in this intersection. It follows that the two highlighted squares outside the intersection must contain the same number. The idea can be better visualised in the example Venn diagram. Both sets are of size six and the intersection is of size five. Hence the pink and blue subsets must be the same single number. Excursus 4.4: The Little Law of Leftovers. 4.6.2: BIG LAW OF LEFTOVERS The Big Law of Leftovers considers the intersection between rows, columns or pieces with regions of the grid. A region could be any selection of squares on the grid, which has at least one of each number within it. Usually it would be a number of adjoining rows or columns, 28

since they clearly include all numbers. When a group of rows, columns or pieces intersect with a region they leave two sets of leftovers. These leftovers must contain the same numbers, as is the case in the Little Law. THE BIG LAW OF LEFTOVERS The Big Law of Leftovers is an extension of the little law. The case here demonstrates an example of the intersection, shaded in grey, of three pieces and the region of the first three rows. The two pink squares lie outside of this intersection, but inside of the three pieces. Likewise the blue squares lie within the rows but not in the intersection. Thus, the numbers contained in the highlighted squares must be the same. The Big Law of Leftovers can obviously be extended to various sizes of sets. Excursus 4.5: The Big Law of Leftovers. 29

5: USABILITY For a program to be regarded as useful it first must be usable. This section details issues which enhance the game's solvability. Firstly, the functionality of the game itself is discussed. Following this, there is a discourse of the Four-Colour Theorem. This is a mathematical result, of particular interest to computer scientists, which I have used in the game. 5.1: THE GAME The program is implemented in Java and Swing using the conventional packages and GUI components. The GUI is a series of labels, buttons and menus. The puzzle itself is created from an array of coloured buttons. Below are some examples of specific functionality within the game. This is just a small selection of the components implemented. Further functions are omitted from discussion due to their tedious nature and the limited size of this report. 5.1.1: SAVING AND LOADING A saving and loading system has been implemented so that a user can put aside a puzzle and return to it at a later time. This is accessible, in the usual way, through a menu. The user can choose a directory and a file-name for the puzzle as required. The data is stored as a list of squares in a file. Each square contains data about its coordinate, the piece it belongs to, the number it contains (if any) and whether it was originally a hint. 5.1.2: CLUES Many Sudoku players keep track of their game by marking their assessed possibilities for each square on the grid. There is an analogue of this within the program. Should the Show Clues button be enabled, the user can hover over a square with the cursor and be presented with a pop-up of the legal possibilities. 30

5.1.3: USER-INPUTTED GRIDS Another thing that a user might want to do is input his own Sudoku or Jigsaw Sudoku puzzles. E.g. They may wish to copy a Sudoku puzzle from a newspaper. It is possible to input grids into the game. Once a puzzle has been inputted, it is treated exactly like a computer generated game. 5.2: FOUR-COLOURING Originally, the shuffled Jigsaw Sudoku grid was coloured with a graduated scheme. I found this to be undesirable due to adjacent pieces being difficult to distinguish and so set about reducing the number of colours used. To this end, I made use of a mathematical result known as the Four-Colour Theorem. The Four-Colour Theorem dates back to 1852 and a South African mathematician Francis Guthrie. 15 Whilst attempting to colour a county map of England, Guthrie noticed that at least four different colours were required so that no two adjacent counties shared a colour. He went on to speculate that four colours were sufficient to shade any map without neighbouring areas sharing a colour. This became known as The Four-Colour Problem and remained unproven until 1976. 16 Figure 5.1: A Comparison of a Graduated vs. a Four-Coloured Grid. 15 Kenneth O'May, 'The Origin of the Four-Color Conjecture', Isis, Vol. 56, No. 3. (Autumn, 1965), pp. 346-348. 16 Robin Wilson. Four Colours Suffice? <http://www.gresham.ac.uk/event.asp?pageid=39&eventid=187> (21 st April 2007). 31

By four colouring the Jigsaw Sudoku grid it could be guaranteed that there was sufficient contrast between adjacent jigsaw pieces, as shown in figure 5.1. A PROOF OF THE FOUR-COLOUR THEOREM The proof of The Four-Colour Theorem is of special interest to Computer Scientists; it was the first mathematical proof dependent on the calculative power of a computer. In the early 1970s, two mathematicians at the University of Illinois, Kenneth Appel and Wolfgang Haken decided that a computer would be the perfect tool for providing a proof. 17 The proof is by contradiction. As is the case with mathematical contradiction, one must assume that there is a case which works and then show it does not. Appel and Haken commenced by assuming that there existed some map that required at least five colours to shade satisfactorily. Building on the work of other mathematicians regarding the Four-Colour Theorem, Appel and Haken created formulas to describe the set of all possible maps. This set reduced the infinity of possible maps to just 1,936 standard maps (later 1,476), 18 all of which were four-colourable. It is a mathematical fact that if there exists maps which require five colours to shade satisfactorily, then there must exist a smallest map requiring five colours. The proof proceeded by showing that such a smallest map cannot exist; any map contained a region within their set or a region reducible to to a member of their set. The calculations in this reduction were achieved using a computer. Since every member of their set is four-colourable it is the case that every map is fourcolourable. Many mathematicians at the time questioned their methods, and disapproved of the use of a computer. Appel and Haken's convoluted proof was not able to be feasibly checked by hand. It was not until a new proof was provided in 1996 that Appel and Haken's proof was accepted in all mathematical circles. 19 Excursus 5.1: A Proof of the Four-Colour Theorem. 17 David Brooks. UNH Magazine Online. Math Pioneers. <http://unhmagazine.unh.edu/sp02/mathpioneers.html> (7 th April 2007). 18 Wikipedia. Four Color Theorem Wikipedia the Free Encyclopedia. <http://en.wikipedia.org/wiki/fourcolor_theorem> (7 th April 2007). 19 Robin Thomas. The Four Color Theorem <http://www.math.gatech.edu/~thomas/fc/fourcolor.html> (20 th April 2007). 32

6: ANALYSIS This chapter covers a statistical experiment to analyse the effect of the number of hints upon the solvability and uniqueness of the grid. In 6.1 the investigation is introduced. Then the experiments used to perform the investigation are detailed. Following this there is a discussion and analysis of the results. Patterns are identified, and thoughts to explain these patterns are considered. 6.4 onwards discusses the mathematics associated with setting the hints. Proofs of theorems are provided and original thoughts into further investigations are outlined. 6.1: HINTS VS. SOLVABILITY As an interesting evaluation, I decided to test the number of random hints placed versus the solvability of the grid. By incrementing the number of hints placed onto the grid, the impact on the solvability could be assessed. The bulk experiment ran as follows: A grid was generated and shuffled, then hints were placed at random onto the grid in a similar manner to the setting algorithm (as described in 4.3). This grid was tested for solvability; if it was found to be unsolvable it was discarded and a count was incremented. Once a solvable grid was found, the count was noted and this process started again. In each test I repeated the experiment 100 times, and repeated these tests six times each (the results are shown in the appendix). The average count was found and then converted into a percentage chance of creating a solvable grid. E.g. If the average count was 5 then the chance of creating a uniquely solvable puzzle would be 20%. Because of the volume of experiments that needed to be completed I only tested 3x3 and 4x4 grids. Larger grids would have taken much longer and, as will be shown, an interesting pattern clearly emerges in just these basic cases. Before running the test, suitable numbers of hints had to be chosen. For a 3x3 grid the number of hints placed could clearly vary from zero to nine. Similarly, for a 4x4 grid the number of hints could vary from zero to 16. Using the 3x3 grid as an example: If nine values were able to be placed on the grid obeying 33

the laws then the puzzle is already solved. Hence N number of hints was discarded. Vacuously, a game with zero hints given has no chance of generating a unique game. In addition it has been proved that for a grid of size N, a set of N 1 hints can lead to a unique solution 20 (this shall be explained later). Hence I chose to test the range N 1 to N 2 1 (i.e. 2 to 8 for the 3x3 example). 6.2: THE 3X3 EXPERIMENT As the graph shows there is an S-shaped curve dependent on the number of hints. From the graph it seems that three is the number of hints required to give the highest chance of generating a uniquely solvable grid. Placing three random hints on to a 3x3 board gives a 45% chance of producing a uniquely solvable game. Six is the number of hints that gives the least chance of generating a uniquely solvable grid. Six hints give a 23% chance of producing a uniquely solvable game. Interesting results occur at the extreme values. I can offer a good explanation for these. At the lower end of the scale, two hints provide less of a chance of generating unique puzzles than three hints. I believe, given two hints placed, there are just too many free variables. This leads to a larger number of grids with many solutions. In this 3x3 case, the effect is limited. The trends are much stronger in the 4x4 case, which is discussed in the next section. Towards the upper limit, the chances of generating a uniquely solvable grid start to rise. In these cases there are less squares left to fill and hence there is a lower chance of creating a contradictory game. Aside from these extremes, the decreasing nature of the graph could indicate an rising number of contradictions. I believe this is a feasible conclusion to draw from the data. 20 Bob Harris, Du-Sum-Oh Puzzles <http://www.bumblebeagle.org/dusumoh/proof/index.html> (27 th April 2007). 34

50 45 40 35 30 25 20 15 10 5 0 2 3 4 5 6 7 8 X-Axis Number of hints placed. Y-Axis Percentage of placements that lead to a unique solution. Hints 2 3 4 5 6 7 8 Mean 2.85 2.24 2.92 3.17 4.30 3.79 3.01 Take the number of hints to be 2. In this case, the likelihood of creating a solvable grid is 1 in 2.85 or 35%. Figure 6.1: Number of Hints Placed vs. Unique Solutions Generated (3x3). 6.3: THE 4X4 EXPERIMENT The 4x4 experiment follows a similar pattern to the 3x3 experiment. The most interesting results of the 4x4 experiment are, again, at the extreme values. In this case the results are amplified. I believe this to be because of the further number of variables available. Overall, in every case there is a lower chance of generating a uniquely solvable puzzle than in the 3x3 experiment. This is due, again, to the extra variables to take into account. 35

I estimate that for larger sized experiments the results will follow the same pattern as the two carried out and that the extremities will give even stronger results. 20 18 16 14 12 10 8 6 4 2 0 3 4 5 6 7 8 9 10 11 12 13 14 15 X-Axis Number of hints placed. Y-Axis Percentage of placements that lead to a unique solution. Hints 3 4 5 6 7 8 9 10 11 12 13 14 15 Mean 21.46 9.31 6.17 6.89 7.45 8.28 12.21 15.44 16.94 18.58 22.17 21.47 7.29 In the case where there are three hints, there is a 1 in 21.46 chance (or 4.7%) of generating a solvable grid. Figure 6.2: Number of Hints Placed vs. Unique Solutions Generated (4x4). 6.4: N 1 HINTS As mentioned earlier, there exist Jigsaw Sudoku puzzles of size N for which N 1 hints lead to a unique solution. This is true for grids of certain shapes, one such shape is detailed below. 36

PROOF OF N 1 HINTS LEADING TO A UNIQUE SOLUTION In January 2006, Bob Harris published the proof An N-1 hint NxN Du-Sum-Oh exists for any N on his website. 21 I shall give a sketch of the proof here. Consider the grid to the left. That is the grid where piece 1 lies in the first N 2 squares of the first row and the first 3 squares of the first column. Piece 2 completes the first row and all but the last square of the second. Piece 3 completes the final column plus the second-last square in the bottom row. This can be extended to any grid of size N in the obvious manner. Firstly place a hint in the second last square of the final row. It follows that all the other squares on this diagonal contain the same number. In the lower example the number placed here would be a 5. From this it is shown that it is sufficient to place hints onto the grid such that there lies N 1 distinct hints on N 1 diagonals, as shown. This is the only solution (excluding the N! Permutations, see 6.6) to the original grid. Excursus 6.1: Proof of N 1 Hints Leading to a Unique Solution Unfortunately no similar lower bound has been found for standard Sudoku puzzles. It is believed that the lower bound is 17 hints. 22 This has not been proven, though no uniquely solvable grids with fewer hints have been found. 21 Bob Harris, Du-Sum-Oh Puzzles <http://www.bumblebeagle.org/dusumoh/proof/index.html> (27 th April 2007). 22 David Bau. Sudoku Generator. <http://davidbau.com/archives/2006/09/04/sudoku_generator.html> (27 th April 2007). 37

6.5: N 2 HINTS In addition to the above proof, I believe that no puzzle of size N can be uniquely solvable given N 2 hints. I provide a proof of this below: PROOF THAT N 2 HINTS WILL NOT LEAD TO A UNIQUE SOLUTION Suppose there exists a Jigsaw Sudoku puzzle of size N which is uniquely solvable given N 2 hints. Given there are N 2 hints placed, there must be two numbers to be placed which are not in the original hints. Since these two numbers are not in the hints they are interchangeable. Hence a unique solution does not exist. Therefore it is not possible for there to exist a grid of size N which is uniquely solvable given N 2 hints. Excursus 6.2: Proof that N 2 Hints will not Lead to a Unique Solution. This proof can be extended to any number less than N 1. Thus N 1 is the minimum number of hints required to generate a solvable grid. 6.6: PERMUTATIONS OF NON-UNIQUE GRIDS For a grid of size N with any n < N distinct hints placed on the board, there are at least (N n)! solutions. Given N 2 hints, it is the case that there are at least 2! permutations (solutions). It is the case (as shown in 6.5) that the two numbers not contained in the hints are interchangeable. The number of permutations of any set are given by n!. For example given a set of three undeclared hints, there are at least 6 possible permutations obtained from interchanging these hints. It is not the case that n! is the maximum number of permutations. Consider a grid with two undeclared hints, it may not be necessary to swap every undeclared number when finding solutions. Take a grid of size three, which has three occurrences of a single hint and two undeclared hints a and b. The following figure represents all of the permutations of the two 38

undeclared hints in the six remaining squares. a a a b b b a a b b b a a b a b a b b a a a b b b a b a b a b b a a a b a b b b a a Figure 6.3: Permutations of a and b in a Grid of Size 3. b b b a a a It follows that for any grid size N with n undeclared hints and N n numbers with all there occurrences, there are at most n N permutations. 39

7: EVALUATION AND EXTENSIONS This, the penultimate chapter, provides an insight into problems faced within the project. It also describes a selection of extensions which have been entertained but not implemented. Firstly the problem of generating large grids is discussed. Two sections follow on the topics of further strategies and choice of difficulty. These issues could be looked at from different angles as either a problem or an extension. The idea of superfluity is then addressed and insight is given into a potential implementation. 7.1: GENERATING LARGE GRIDS The one major problem with the project is the generation of large grids. Grids smaller than 6x6 are created almost instantly, whilst 7x7 grids usually take less than 20 seconds to make. Larger grids than this do not seem feasible given my current algorithms. Much of the problem lies in the way the grids are created. Given that 4x4 grids take on average roughly twelve attempts to generate a solvable puzzle (as shown in 6.3), the problem with larger grids become obvious. The algorithms used to generate the grids are clearly not optimal. Saying this, they do serve their purpose, and given a longer period of time could be much improved. I feel that a good deal of the trouble generating large grids could be put down to the order in which I designed the project. Had I implemented the solution first I could have used this to narrow down the possibilities. 7.2: FURTHER STRATEGIES There are literally dozens of well documented strategies available for Sudoku. Many programmers and hobbyists spend years researching, collecting and implementing new strategies in their spare time. It would not be possible to create a complete Sudoku solver within the time prescribed for this project. In addition to this, I believe it would not add value. Implementing the extra 40

strategies would simply be a case of researching descriptions and designing a version in code. 7.3: CHOICE OF DIFFICULTY A possible extension is to implement a system that allows a choice of difficulty. Below is a suggestion of how this could be completed. Firstly the known strategies of the game must be grouped based on their perceived difficulty. For this example, say that the strategies are placed into three groups: novice, intermediate and advanced. To assess the difficulty of the generated game, it is sufficient to check which strategies are needed to solve it. Thus, once a game has been created, the computer shall attempt to solve the game from its bank of strategies. For example: if the computer is able to solve the game using only novice strategies then the game would be classed as easy. Whilst this sounds straightforward it does have flaws. The computer would have to know all possible solving strategies; if it was missing a novice strategy then it might regard the game to be more difficult than it actually is. Also, it is very hard to categorise the level of different strategies; this is a highly subjective matter, a strategy that one player may find easy, another player may not be able to grasp. A much harder thing to do would be to let the player select the difficulty of the game before generation. This is why I believe the vast majority of on-line Sudoku puzzles rely on ready made puzzles, rather than generating a game based on the user's required level. The only feasible method I could see of achieving this would be to generate a series of games and checking their solvability until finding one at the required level. This could be very time consuming; since the boards are randomly generated, the worst case could be never being able to find a game of the required difficulty. 7.4: SUPERFLUITY A placed hint is called superfluous if it can be deduced from the other hints in the Sudoku puzzle. Consider figure 7.1, in the left hand grid there is a 3 placed at (4,2). In the right hand grid this 3 has been removed, yet the game can still be solved. Hence this 3 is superfluous. Many people consider Sudoku puzzles which contain superfluous hints to be undesirable. One member of sudoku.org.uk succinctly states In my opinion any Sudoku which contains 41

any superfluous clue is thereby aesthetically flawed. 23 Figure 7.1: Superfluous Hints. I would have liked to implement a method of removing superfluous hints within the program. Again there simply was not enough time. I imagine it being a straightforward, yet tedious, algorithm to implement. It may suffice to remove one hint from the grid in turn, and to check the possibles given at the now empty square. A variation of this algorithm could be used to generate a grid with the minimal number of hints. Consider a completed Sudoku puzzle and the set of all the numbers placed in this puzzle. There must be a smallest subset of these numbers that generate the remainder of the set. This subset could be called minimal. There exists a minimal number of hints for any given Jigsaw Sudoku. A potential algorithm to generate a minimal set of hints could involve placing and removing hints dependent on their superfluity. To achieve these algorithms with good effect, the program would need to have a large bank of strategies at its disposal. Since the program does not have a large bank of strategies, any attempt at identifying superfluity would have been flawed from the outset. 23 Gurth Bruins. Sudoku Discussions. <http://www.sudoku.org.uk/discus/messages/29/2313.html?1155827002> (29 th April 2007). 42