The Mathematics of Sudoku Helmer Aslaksen Department of Mathematics National University of Singapore

Slides:



Advertisements
Similar presentations
Can you master it?. Sudoku Hype Sudoku is a logic-based number placement puzzle. The objective is to fill a 9×9 grid so that each column, each row, and.
Advertisements

Techniques for Solving Logic Puzzles. Logic Puzzles Logic puzzles operate using deductive logic. Logic puzzles operate using deductive logic. A well-designed.
How to play SUDOKU adapted from Tilda Rosander.
SAT Encoding For Sudoku Puzzles
Message-Passing and Sudoku Scott Kirkpatrick, HUJI Danny Bickson, HUJI TAU, June 18, 2006.
Number puzzles in the paper Did you know there’s a whole range of number puzzles you can try in most newspapers? Click on the puzzles below to complete.
Playing Fair at Sudoku Joshua Cooper USC Department of Mathematics.
Eight queens puzzle. The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard such that none of them are able to capture.
Problem of the Day Problem of the Day next Geometry - Connect the Dots
Algebra and Sudoku By Ashley MacDonald Math 354: Modern Algebra 1
Structured Graphs and Applications
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
The Mathematics of Sudoku
Latin Squares Jerzy Wojdyło February 17, Jerzy Wojdylo, Latin Squares2 Definition and Examples A Latin square is a square array in which each row.
Link-A-Pix and Fill-A-Pix The lesser known relatives of Paint By Numbers.
Sudoku Rules Now in PowerPointVision! Tyler “The Admiral” Hinman.
A game of logic where the player must assign the numbers 1..9 to cells on a 9x9 grid. The placement of the numbers must be such that every number must.
Using Reduction for the Game of NIM. At each turn, a player chooses one pile and removes some sticks. The player who takes the last stick wins. Problem:
SOLVING SUDOKU Graham Hutton University of Nottingham (with thanks to Richard Bird)
Examining the top three rows first Row two requires a 5. It has to be located in the middle 3x3 box. Two possible locations for 5 in centre box The centre.
Chapter 11 Section 11.0 Review of Matrices. Matrices A matrix (despite the glamour of the movie) is a collection of numbers arranged in a rectangle or.
Mathematics Long Multiplication.
Solving Sudoku Mark PTTLS Micro teach. Solving Sudoku What is a Sudoku? A Sudoku is a number puzzle based on a 9x9 grid made up from smaller 3x3 blocks.
More Computational Curiosities of Sudoku ( 数独 ) Bryson R. Payne, Ph.D. North Georgia College & State University.
Mathematical Methods In Solving Sudoku Puzzles By: Cory Trenkamp Wright State University May 24, 2006.
CS194 Project: Sudoku Difficulty Kha Chu Advisor: Professor Sahai.
SUDOKU Via Relaxation Labeling
Sudoku Puzzles Frank Hilvers Taylor O’Brien. The History of Sudoku The history of Sudoku puzzles dates back to the 18th century.  Swiss mathematician.
Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014.
Set Theory Topic 1: Logical Reasoning. I can determine and explain a strategy to solve a puzzle. I can verify a strategy to win a game. I can analyze.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Teaching Students to Invent Puzzles Scott Kim shufflebrain.com Math Fair Workshop April 21, 2007.
2009/11/14GPW20091 Analysis of the Behavior of People Solving Sudoku Puzzles Reijer Grimbergen School of Computer Science, Tokyo University of Technology.
1 CS 410 Mastery in Programming Chapter 10 Hints for Simple Sudoku Herbert G. Mayer, PSU CS Status 7/29/2013.
Patent Pending New Minimum Number of Clues Findings to Sudoku-derivative Games up to 5-by-5 Matrices including a Definition for Relating Isotopic Patterns.
Computing Science 1P Large Group Tutorial 20 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Whiteboardmaths.com © 2008 All rights reserved
Get Into Sudoku! How to play and how to become an expert.
Sudoku Solver Comparison A comparative analysis of algorithms for solving Sudoku.
HKOI2006 Analysis and Solution Junior Q3 – Sudoku HKOI Training Team
CS1Q Computer Systems Lecture 7
1 Project Management Example Solving Sudoku 2 What is Sudoku?  Sudoku is a game with 9 columns and 9 rows and 9 “boxes” composed of a 3 x 3 Grid  Numbers.
To create a program, written in C++, that could generate a Sudoku. Elements to take into consideration: The Sudoku created must have one unique solution.
June 12, 2002© Howard Huang1 Karnaugh maps Last time we saw applications of Boolean logic to circuit design. – The basic Boolean operations are.
How Do I Solve This Thing?. You are familiar with Sudoku puzzles. For this variation, place the integers 1 – 9 into each row or column such that the.
4 Mathematical Programming tools Mutually Orthogonal Latin Squares (MOLS) G Appa, R Euler, A Kouvela, D Magos, Y Mourtos, & A Tran.
Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9x9 grid with digits so that each column, each row, and each.
CompSci Problem Solving: Sudoku  Rules of the Game Sudoku is played with a 9 by 9 "board" consisting of nine 3 by 3 sub-boards. The symbols 1 -
By Luke. What is Sudoku? Sudoku is a number game it has 81 squares. The only numbers you can use are 1,2,3,4,5,6,7,8 and 9.
SUDOKU SOLVER Will Bazil, Ryan Covert, Ricky Parker.
Optimized SAT Encoding For Sudoku Puzzles Will Klieber and Gi-Hwon Kwon Sept 27, 2007 rev. 2 Changes from v1: Added a new slide after “A Better Encoding.
Combinatorial Designs and Their Applications ( 組合設計及其應用 ) 應用數學系 傅恆霖.
Name: Aimee McLaughlin
Teacher Notes Supplies Needed: Class set of sudoku puzzles.
Bipartite Matching Lecture 8: Oct 7.
How Many Ways Can 945 Be Written as the Difference of Squares?
CS 352 Introduction to Logic Design
Legos, lunch time, and lollipops Two-way Frequency Tables
Patrick MacKinnon & Claude-Michelle Chavy-Waddy
Vector nakes and L A D D E R S.
Example Fill in the grid so that every row, column and box contains each of the numbers 1 to 9:
9.3 Lego’s, Lunch and Lots More Two-way Frequency Tables
The mathematics behind sudoku
Modeling Sudoku as a CNF Formula
Sudoku (数独 sūdoku?), also known as Number Place or Nanpure, is a logic-based placement puzzle. The objective is to fill the grid so that every column,
Topic Past Papers –Linear Equations
Breakfast Bytes Easy, Hard, and Impossible
Sudoku.
Karnaugh maps Last time we saw applications of Boolean logic to circuit design. The basic Boolean operations are AND, OR and NOT. These operations can.
Lecture 8 Nash Equilibrium
Presentation transcript:

The Mathematics of Sudoku Helmer Aslaksen Department of Mathematics National University of Singapore

Sudoku grid 9 rows, 9 columns, 9 3x3 boxes and 81 cells I will refer to rows, columns or boxes as units (p,q) refers to row p and column q I number the boxes left to right, top to bottom

Rules Fill in the digits 1 through 9 so that every number appears exactly once in every unit (row, column and box) Some numbers are given at the start to ensure that there is a unique solution

History of Sudoku Retired architect Howard Garns of Indianapolis invented a game called “Number Place” in May 1979 Introduced in Japan in April1984 under the name of Sudoku ( 数独 ), meaning single numbers Took the UK by storm in late 2004

Latin squares In 1783, Euler introduced Latin squares, i.e., n x n arrays where 1 through n appears once in every row and column A Sudoku grid is a 9x9 Latin square where the 9 3x3 boxes contains 1 through 9 once

How many givens do we need to guarantee a unique solution? This is an unknown mathematical problem There are examples of uniquely solvable grids with 17 givens ( n.php)

How many givens can we have without guaranteeing a unique solution?

How many Sudoku grids are there? It was shown in 2005 by Bertram Felgenhauer and Frazer Jarvis to be 6,670,903,752,021,072,936,960 This is roughly % the number of 9×9 Latin squares

Why Sudoku is simpler than real life If a number can only be in a certain cell, then it must be in that cell

Elementary solution techniques We will first describe three easy techniques Scanning (or slicing and dicing) Cross-hatching Filling gaps

Scanning We can place 2 in (3,2) You should start scanning in rows or columns with many filled cells Scan for numbers that occur many times

Cross-hatching

Filling gaps Look out for boxes, rows or columns with only one or two blanks

Intermediate techniques The elementary techniques will solve easy puzzles I will discuss one intermediate technique, box claims a row (column) for a number

Box claims a row (column) for a number Box 1 claims row 1 for number 1 We can place 1 in (3,8)

Box claims a row (column) for a number Box 2 claims row 3 for number 8 We can place 8 in (2,9) This is sometimes called “pointing pairs/triples”

Advanced techniques For harder puzzles, we must pencil in candidate lists This is called markup

Candidate Lists

Strategy If you believe the puzzle is easy, you should be able to solve it using easy techniques and it is a waste of time to write down candidate lists If you believe the puzzle is hard, you should not waste your time with too much scanning, and go for candidate lists after some quick scanning

Single-candidate cell 5 is the only candidate in (3,3) Called a naked single

Single-cell candidate (1,2) is the only square in which 6 is a candidate Called a hidden single

Strategy Once you fill one cell, you must update all the affected candidate lists Search systematically for naked or hidden singles in all units

Naked pairs Cells 2 and 5 only contain 1 and 7 Hence 1 and 7 cannot be anywhere else! We can remove 1 and 7 from the lists in all the other cells

Hidden pair 6 and 9 only appear in cells 1 and 5 Hence we can remove all other numbers from those two cells, {6, 9} becomes a naked pair and we get a hidden {1}

Naked triples Cells 2, 3 and 7 only contain a subset of {3, 5, 6} Hence 3, 5 and 6 cannot be anywhere else We can remove 3, 5 and 6 from the lists in all the other cells

Naked triples Notice that none of the three cells need to contain all three numbers {3, 5, 6} still forms a triple in cells 2, 3 and 7 even though all the three lists only contain pairs

Naked and hidden n-tuples We can generalize the pairs and triples to naked and hidden n-tuples If n cells can only contain the numbers {a 1,…, a n }, then those numbers can be removed from all other cells in the unit If the n numbers {a 1,…, a n } are only contained in n cells in an unit, then all other numbers can be removed from those cells

Naked or hidden? Naked means that n cells only contain n numbers Hidden means that n numbers are only contained in n cells Naked removes the n numbers from other cells Hidden removes other numbers from the n cells Hidden becomes naked

Row (column) claims box for a number In the middle row, 2 can only occur in the last box Hence we can remove it from all the other cells in the box Also called “box line reduction strategy”

Row (column) claims box for a number vs. box claims row (column) for a number Row claims box for a number means that if all possible occurrences of x in row y are in box z, then all possible occurrences of x in box z are in row y Box claims row for a number means that if all possible occurrences of x in box z are in row y, then all possible occurrences of x in row y are in box z

More advanced techniques X-Wing Swordfish XY-wing

X-Wing We can remove the 6's marked in the small squares and we can place 9 in (7,9).

X-Wing Theory Suppose we know that x only occurs as a candidate twice in two rows (columns), and that those two occurrences are in the same columns (rows) Then x cannot occur anywhere else in those two columns (rows)

Swordfish This is just a triple X-wing Suppose we know that x occurs as a candidate at most three times in three rows (columns), and that those occurrences are in the same columns (rows) Then x cannot occur anywhere else in those three columns (rows)

Swordfish 2 We can place a 2 in (5,2)

Swordfish 3 We don’t need nine candidate lists

XY-wing We can eliminate z from the cell with a “?” If there is an x in the top left cell, there has to be a z in the top right cell If there is a y in the top left cell, there has to be a z in the bottom left cell

XY-wing We don’t need a square; it is enough that there are three cells of the form xy, xz and yz, where the xy is in the same unit as xz and the same unit yz We can eliminate z from the gray cells below

What if you’re still stuck? Sometimes even these techniques don’t work You may have to apply “proof by contradiction” Choose one candidate in a list, and see where that takes you If that allows you to solve the grid, you have found a solution

Proof by contradiction If your assumption leads to a contradiction, you can strike that number off the candidate list in the cell Unfortunately, you may have to “branch” at several cells

Solution by “logic”? Some people do not approve of proof by contradiction, claiming that it is not logic It is obviously valid logic, but it is hard to do with pen and paper

Where can I get help? There are many Sudoku solvers available online Many of them allow you to step through the solution, indicating which techniques they are using

Warning! Sudoku is fun, but it is highly addictive Happy Sudoku!

Sample Puzzle

Sample Puzzle 2