The Mathematics of Sudoku

Slides:



Advertisements
Similar presentations
On the Density of a Graph and its Blowup Raphael Yuster Joint work with Asaf Shapira.
Advertisements

1 More Counting by Mapping Lecture 16: Nov 7. 2 This Lecture Division rule Catalan number.
Playing Fair at Sudoku Joshua Cooper USC Department of Mathematics.
From Topological Methods to Combinatorial Proofs of Kneser Graphs Daphne Der-Fen Liu 劉 德 芬 Department of Mathematics California State University, Los Angeles.
Section 1.7: Coloring Graphs
Matrices: Inverse Matrix
Induction and recursion
Burnside’s lemma and beyond: Permutations of vertices and color by Lucas Wagner.
Algebra and Sudoku By Ashley MacDonald Math 354: Modern Algebra 1
Fast FAST By Noga Alon, Daniel Lokshtanov And Saket Saurabh Presentation by Gil Einziger.
Structured Graphs and Applications
How to Choose a Random Sudoku Board Joshua Cooper USC Department of Mathematics.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Contents Introduction Related problems Constructions –Welch construction –Lempel construction –Golomb construction Special properties –Periodicity –Nonattacking.
1 Shira Zucker Ben-Gurion University of the Negev Advisors: Prof. Daniel Berend Prof. Ephraim Korach Anticoloring for Toroidal Grids.
(work appeared in SODA 10’) Yuk Hei Chan (Tom)
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
Alternating Sign Matrices and Symmetry (or) Generalized Q*bert Games: An Introduction (or) The Problem With Lewis Carroll By Nickolas Chura.
Graphs, relations and matrices
The Mathematics of Sudoku Helmer Aslaksen Department of Mathematics National University of Singapore
Function: Definition A function is a correspondence from a first set, called the domain, to a second set, called the range, such that each element in the.
Linear Functions and Modeling
5  Systems of Linear Equations: ✦ An Introduction ✦ Unique Solutions ✦ Underdetermined and Overdetermined Systems  Matrices  Multiplication of Matrices.
Patrick March, Lori Burns. History Islamic thinks and the discovery of the latin square. Leonhard Euler, a Swiss mathematician from the 18 th century,
Systems of Equations and Inequalities
The Minimum Number of Givens in a Fair Sudoku Puzzle (is 17!) Joshua Cooper USC Department of Mathematics.
Systems and Matrices (Chapter5)
Invariant Method
2015/9/81 Advisor : Chih-Hung Yen Student : Chia-Ying Wu 2015/9/811.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Matrix Completion Problems for Various Classes of P-Matrices Leslie Hogben Department of Mathematics, Iowa State University, Ames, IA 50011
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006.
SOLIDWORKS: Lesson II – Revolutions, Fillets, & Chamfers UCF Engineering.
Warm Up #5.
Petrie maps and Petrie configurations Jurij Kovič, University of Primorska, Slovenia EuroGIGA Final Conference Berlin, February 20, 2014.
Chapter 9: Geometric Selection Theorems 11/01/2013
1 On Completing Latin Squares Iman Hajirasouliha Joint work with Hossein Jowhari, Ravi Kumar, and Ravi Sundaram.
HKOI2006 Analysis and Solution Junior Q3 – Sudoku HKOI Training Team
1 Rainbow Decompositions Raphael Yuster University of Haifa Proc. Amer. Math. Soc. (2008), to appear.
Monochromatic Boxes in Colored Grids Joshua Cooper, USC Math Steven Fenner, USC CS Semmy Purewal, College of Charleston Math.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Matrix Completion Problems for Various Classes of P-Matrices Leslie Hogben Department of Mathematics, Iowa State University, Ames, IA 50011
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 4 Inverse, Exponential, and Logarithmic Functions Copyright © 2013, 2009, 2005 Pearson Education,
Overview Excel is a spreadsheet, a grid made from columns and rows. It is a software program that can make number manipulation easy and somewhat painless.
Latin squares Def: A Latin square of order n is a quadruple (R, C, S; L) where R, C and S are sets of cardinality n and L is a mapping L: R × C → S such.
1 INFO 2950 Prof. Carla Gomes Module Induction Rosen, Chapter 4.
Chapter 29 Symmetry and Counting. Consider the task of coloring the vertices of a regular hexagon so that three are black and three are white. There are.
4 Mathematical Programming tools Mutually Orthogonal Latin Squares (MOLS) G Appa, R Euler, A Kouvela, D Magos, Y Mourtos, & A Tran.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Introduction to Graph Theory Lecture 13: Graph Coloring: Edge Coloring.
Introduction to Graph Theory
Mathematical Induction
Date: 1.2 Functions And Their Properties A relation is any set of ordered pairs. The set of all first components of the ordered pairs is called the domain.
1 Finding a decomposition of a graph T into isomorphic copies of a graph G is a classical problem in Combinatorics. The G-decomposition of T is balanced.
SECTION 2 BINARY OPERATIONS Definition: A binary operation  on a set S is a function mapping S X S into S. For each (a, b)  S X S, we will denote the.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
拉丁方陣 交大應數系 蔡奕正. Definition A Latin square of order n with entries from an n-set X is an n * n array L in which every cell contains an element of X such.
Copyright © 2009 Pearson Education, Inc. 7.1 Seeking Correlation LEARNING GOAL Be able to define correlation, recognize positive and negative correlations.
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 ( 組合設計及其應用 ) 應用數學系 傅恆霖.
CHAPTER 9: RATIONAL FUNCTIONS. 9.1 INVERSE VARIATION.
Fifteen Puzzle Move: can move a square adjacent to the empty square to the empty square.
Bipartite Matching Lecture 8: Oct 7.
Patrick MacKinnon & Claude-Michelle Chavy-Waddy
The mathematics behind sudoku
Presentation transcript:

The Mathematics of Sudoku Joshua Cooper Department of Mathematics, USC

Rules: Place the numbers 1 through 9 in the 81 boxes, but do not let any number appear twice in any row, column, or 33 “box”. Usually you start with a subset of the cells labeled, and try to finish it. 1 3 7 8 4 5 9 2 6 6 5 4 2 8 3 2 6 1 5 9 9 2 4 7 6 1 3 4 7 5 3 3 1 2 9 4 6 5 8 7 5 3 9 4 5 9 6 1 3 7 2 2 3 6 9 5 8 4 4 2 9 6

Seemingly innocent question: How many sudoku boards are there? The same? We could define a group of symmetries – flips, rotations, color permutations, etc. – and only count orbits. Let’s just say that two boards are the same if and only if they agree on every square. Recast the question as a “hypergraph” coloring problem.

Graph: A set (called “vertices”) and a set of pairs of vertices (called “edges”). Example. V = {1,2,3,4,5}, E = {{1,2},{2,3},{3,4},{4,5},{1,5},{1,4},{2,4}}. 1 2 5 4 3 Hypergraph: A set (called “vertices”) and a set of sets of vertices (called “edges” or sometimes “hyperedges”). If all the edges have the same size k, then the hypergraph is said to be k-uniform. In particular, a 2-uniform hypergraph is just a graph.

Example of a 3-uniform hypergraph: The “Fano Plane”, V = {1,2,3,4,5,6,7} and A k-coloring of a graph G is an assignment of one of k colors to the vertices of G so that no edge has two vertices of the same color. Alternatively: A k-coloring of a graph G is an assignment of one of k colors to the vertices of G so that no edge is monochromatic (i.e., has only one color on it).

Typical Graph Coloring Questions: Does there exists a coloring of G with k colors? What is the fewest number of colors one can color G with? (“Chromatic Number”, denoted (G).) How many colorings are there of G with k colors? (“Chromatic Polynomial”, often denoted PG(k).) For hypergraphs, colorings are more complicated. Our previous definitions split! A strong k-coloring of a hypergraph G is an assignment of one of k colors to each of the vertices of G so that no edge has two vertices of the same color. A weak k-coloring of a hypergraph G is an assignment of one of k colors to each of the vertices of G so that no edge is monochromatic. (Then there are colorings in which each edges has an even number of colors, colorings where no edge gets exactly 7 colors, etc.)

Every strong coloring is a weak coloring, but not vice versa: Weak Chromatic Number = 3 Strong Chromatic Number = 7 Note that any strong coloring of a k-uniform hypergraph must use at least k colors, since each edge needs at least that many. What does this have to do with Sudoku?

A completed Sudoku is a strong 9-coloring of the following 9-uniform hypergraph H on 81 vertices: Removing the squiggly edges gives a “Latin Square.” A Sudoku puzzle is a partial coloring of H that the player is supposed to complete to a strong coloring of the entire hypergraph. It is proper if there is exactly one way to do this. So, our enumeration question becomes: How many strong colorings of H are there?

Consider 44 generalized Sudoku: Can we just check all the possible 4-colorings, and count only those that are strong? 42 = 16 cells, 4 colors, means 416 = 4294967296 colorings. At 10000 a second, it would take 5 days to do this. But we can cut it down by quite a bit with some cleverness. First of all, it is safe to fix the upper left block – and then multiply the number of total strong colorings by 4! = 24, the number of ways to permute the colors. Now the count is 412 = 16777216, which would take 28 minutes to do.

Note that swapping two columns or rows in the same block preserves the property of being a strong coloring: This means we can assume that the yellow square in the lower right block is in the upper right corner… and then multiply by 4. Total number of colorings to check: 411 = 4194304 = 7 min.

Here’s what we can assume now, and the multiplier is 24·4 = 96. 0 options 96·3 = 288 1 option 2 options

I II III A B C ≈ 2 1077 Okay, how about 99 real Sudoku? Number of colorings : 981 = 196627050475552913618075908526912116283103450944214766927315415537966391196809 ≈ 2 1077 Even if we fix the colors of the upper left block (i.e., divide by 9! = 362880), at 1000000 colorings per second, this would still take 1.7 1058 years. (The universe is 13.7 109 years old.) But, we can permute the rows and columns of each block… I II III A B C And permute block-rows I, II, and III, and block-columns, A, B, and C… So, with careful counting, it is possible to reduce the number of combinatorially distinct triples of top block-rows to 44. For each one, the number of ways to complete the table is “reasonable”.

Number Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Number of equivalent configurations Number of completions to a full grid 1 1,2,4 3,5,7 6,8,9 1,2,5 3,6,7 4,8,9 2484 97961464 2 3,6,8 4,7,9 2592 97539392 3 3,6,9 4,7,8 1296 98369440 4 3,7,8 4,6,9 1512 97910032 5 1,2,6 3,4,8 5,7,9 2808 96482296 6 3,4,9 5,7,8 684 97549160 7 97287008 8 3,5,8 1944 97416016 9 3,5,9 2052 97477096 10 1,2,7 5,6,9 288 96807424 11 864 98119872 12 1,2,8 3,4,7 1188 98371664 13 648 98128064 14 4,5,7 98733568 15 1,3,5 2,6,9 97455648 16 2,7,8 360 97372400 17 1,3,6 2,5,9 3240 97116296 18 1,3,8 2,6,7 4,5,9 540 95596592 19 756 97346960 20 1,4,5 324 97714592 21 432 97992064 22 1,4,6 2,3,9 98153104

Number Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Number of equivalent configurations Number of completions to a full grid 23 1,2,4 3,5,7 6,8,9 1,4,7 2,6,9 3,5,8 864 98733184 24 1,4,8 108 98048704 25 1,5,6 2,3,9 4,7,8 756 96702240 26 6,7,9 1,2,5 3,6,8 4,7,9 516 98950072 27 1,2,6 3,4,8 5,7,9 576 97685328 28 1,2,7 4,6,9 432 98784768 29 1,3,7 4,5,8 324 98493856 30 2,5,8 3,6,9 72 100231616 31 3,7,8 216 99525184 32 2,3,7 4,8,9 252 96100688 33 3,5,9 6,7,8 3,5,6 288 96631520 34 4,6,8 97756224 35 99083712 36 2,6,8 98875264 37 5,7,8 102047904 38 144 101131392 39 1,3,5 2,6,7 96380896 40 102543168 41 3,7,9 5,6,8 1,4,6 12 99258880 42 2,4,9 20 94888576 43 4,5,9 97282720 44 4 108374976

Take Σ (# equivalent configurations)·(# ways to complete the table), i Take Σ (# equivalent configurations)·(# ways to complete the table), i.e., the dot product of the blue and red columns… i=1 44 Then multiply by 1881169920 = 9!·722 (the number of elements in each orbit under the relevant permutation group), and you get… 6,670,903,752,021,072,936,960. (6.7 sextillion) For the details of the reduction, see: and Frazer, Jarvis, Enumerating Possible Sudoku Grids, 2005. http://www.afjarvis.staff.shef.ac.uk/sudoku/ed44.html (If you don’t count two Sudoku tables as different when one can be obtained from the other by permuting in-block columns, permuting in-block rows, permuting block-columns, permuting block-rows, permuting colors, rotation, or reflection, there are exactly 5,472,730,538 different tables.)

Happy Sudokuing! Some Open Questions 1. What is the fewest number of cells in any proper Sudoku puzzle? Conjecture: 17. As of September 2008, there are 47793 such puzzles known (Gordon Royle maintains a list), and none with 16 known. 2. How many 1616 Sudoku boards are there? Conjecture: About 5.9584×1098. 3. How many n2n2 Sudoku boards are there, asymptotically? 5. What’s the largest rectangular “hole” in a proper Sudoku puzzle? (Conjecture: 56.) 4. What fraction of Latin squares are Sudoku boards? Happy Sudokuing!