Math behind Sudoku
Alejandra Cruz
IB Math SL
What are the mathematical concepts used in solving a sudoku puzzle?
When playing sudoku, I never thought
there was actual math behind the puzzle.
For me, it always seemed to be about
numbers and how/where you place them.
In total, there can only be whole numbers
(1-9) in each row (in pink), in each
column (in purple) and in each box (in
blue). A number cannot be repeated twice
in each of the different sections. But when
learning about game theory, which 1is the
study of human conflict and cooperation
within a competitive situation, I was able to understand a little more about the strategies and
math behind the puzzle.
In this investigation, I will use a puzzle that I love solving, sudoku, to understand simple math
and strategies used to solve this game. It would be interesting to discover and investigate the
different principles and rules that go into this puzzle and how it is used. This can be done by
going through the steps that it takes to solve a sudoku puzzle, but first I will need to define some
key terms that will be used throughout the paper other than those already addressed in the
paragraph above:
- A square represents one of the 81 squares that make up the grid for the puzzle
- A candidate is a possible number that can be used in a square
- A solid number is a number that for sure goes into a square because on the placement of
the other numbers
- Group refers to a box, row and column-where there must be numbers 1-9
1
https://www.investopedia.com/terms/g/gametheory.asp
1
In order to get my point across behind how math is needed to solve a sudoku puzzle, a puzzle
needs to be solved step by step. Let's start with this easy one:
When initially looking at this puzzle, it is important to look for the number most commonly used
to find places where a solid number can be placed. For example, let's start with the number 8.
When looking at the two eights in the top row of boxes and the other two eights in the right hand
column of boxes, there can be one solid number in the bottom right square in the upper right
hand box. Then we can look at 3. It is noticeable that when looking at the 3’s in the middle
blocks, that a solid number for this integer would be in the middle of the last row.
Here is what it would look like:
2
Now here is a little bit of math behind it. There is a concept called permutations which 2 is an
order of symbols, or in this case numbers because as mentioned earlier, there can only be one
occurrence of a single number in each group. The number of each permutation according to the
Sudoku Dragon, depends on the factorial. A factorial is a 3 product that is indicated by an
exclamation mark. To illustrate, for a sudoku puzzle, if we were to pull out and separate a 3 by 3
empty box, then we could use the numbers 1-9 in any order throughout the box. This results in a
nine factorial, which is 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 362, 880 possible permutations. 4The
number of permutations of n objects taken r at a time is determined by the following formula as
well:
P(n,r)=n!/(n−r)!
For a sudoku puzzle, there needs to be 9 digits in a specific order, the digits are 1-9. In order to
determine the correct number of permutations we simply plug and chug:
9! 9!
P(n,r)= (9!−9!)
= 0!
= 362, 880
In this sudoku puzzle, the number of factorials per
box can be determined by analyzing the placing of
the solid numbers. In the top left hand box, there can
only be 7 factorials because there are two solid
numbers already placed there. That means that if we
ignore the rules (rows and columns) and filled in the
box randomly with the numbers left over, there
7!
would be P(n,r)= (7!−7!)
= 5,040 possible outcomes.
2
http://www.sudokudragon.com/sudokutheory.htm
3
http://www.purplemath.com/modules/factorial.htm
4
https://www.mathplanet.com/education/algebra-2/discrete-mathematics-and-probability/permutations-and
-combinations
3
It is important to know this when deciding what numbers to put in each square because
sometimes, when left with a group that is missing two numbers, the easy way is to guess and see
if everything adds up in the end but by doing this, the whole puzzle will be changed and it might
not work out. To illustrate, here is the puzzle that was being solved on the last page:
If we focus on the two numbers, 1 and 9, it is noticeable how one version (on the left) actually
works out, but on the right the puzzle can’t be completed if the 1 and 9 in the left puzzle are
flipped. This is because there has to be a nine in the bottom square of the middle column but
that's also the only place in the box where a three can go.
It is important to understand these concepts and rules behind the puzzle in order to be able to
solve them. Permutations is needed for the player to know that there are several ways to go about
the sudoku puzzle, but after reading different articles it came to my attention that published
printed sudoku puzzles only have one right answer meaning that despite the permutations
discussed in this paper, there is actually one one permutation. However there are a variety of the
steps that can be taken to solve a sudoku puzzle. Each group needs to be evaluated and by
knowing the permutations (or order of the symbols/numbers) it is clear what needs to be done
and how it can be done. For example, when looking at each box, there are definite numbers given
4
that cannot be changed and there are a certain number of integers from 1-9 that are left and with
this factorial, we are able to deduce how many possible outcomes there are in solving this 3 by 3
box which will then be helpful in solving the rest of the puzzle. This is why in the end, the final
result of the puzzle should look like this:
5
Bibliography
Davis, Tom. “The Mathematics of Sudoku.” 13 Sept. 2012.
http://www.geometer.org/mathcircles/sudoku.pdf
Moran, Laurence A. “I Knew It: There Can Be More than One Solution to a Sudoku Puzzle!”
Sandwalk, 8 June 2007, sandwalk.blogspot.com/2007/06/i-knew-it-there-can-be-more-
than-one.html
“Permutations and combinations (Algebra 2, Discrete mathematics and probability) –
Mathplanet.” Mathplanet, www.mathplanet.com/education/algebra-2/discrete-
mathematics-and-probability/permutations-and-combinations.
Stapel, Elizabeth. Factorials, www.purplemath.com/modules/factorial.htm.
Staff, Investopedia. “Game Theory.” Investopedia, 15 Apr. 2016,
www.investopedia.com/terms/g/gametheory.asp.
Sudoku Puzzle Theory, www.sudokudragon.com/sudokutheory.htm.