Stable Marriage Problem and Sudoko
Stable Marriage Problem and Sudoko
Matvey Borodin, Eric Chen, Aidan Duncan, Boyan Litchev, Jiahe Liu,
Veronika Moroz, Matthew Qian, Rohith Raghavan, Garima Rastogi, and
Michael Voigt
arXiv:2108.02654v1 [math.HO] 4 Aug 2021
PRIMES STEP
Tanya Khovanova
MIT
August 6, 2021
Abstract
Are you having trouble getting married? These days, there are lots of products on
the market for dating, from apps to websites and matchmakers, but we know a simpler
way! That’s right — your path to coupled life isn’t through Tinder: it’s through
Sudoku! Read our fabulous paper where we explore the Stable Marriage Problem to
help you find happiness and stability in marriage through math. As a bonus, you get
two Sudoku puzzles with a new flavor.
1 Introduction
The stable marriage problem (SMP) is the problem of matching n men and n women into
married couples depending on their preferences so that the matching is stable. To make
it easier to define a stable matching, we first define an unstable matching. An unstable
matching is a matching such that there exist two people who prefer each other to their
partners. Thus, a stable matching is a matching where no such pairs of people exist.
In a famous paper dating back to 1962, Gale and Shapley [1] suggested an algorithm,
now called the Gale-Shapley algorithm, that always finds a stable matching. Theoretically,
it is possible to have distinct stable matchings for the same set of preferences. The original
Gale-Shapley algorithm is based on men proposing to women. It favors men; that is, the
result is man-optimal and woman-pessimal.
1
The stable marriage problem is extremely versatile as it can be applied to matching
applicants and jobs, users and servers, and so on. Because of its numerous applications, it
attracts a lot of researchers. But now, it is time to turn to Sudoku.
A Sudoku is a logic puzzle played on a partially-filled 9 by 9 grid. The objective is to
complete the grid by filling it with the integers 1 through 9 so that every row, column, and
3 by 3 block contains distinct digits. Note that the blocks are the nine non-overlapping 3 by
3 subgrids. By tradition, a Sudoku puzzle has a unique solution. The mathematics behind
Sudoku is covered in an awesome book by Rosenhouse and Taalman [3].
How is the stable marriage problem related to Sudoku? This is what this paper is about.
One of the main goals of the paper is to draw parallels between SMP and Sudoku. While
doing this, we invented a new type of Sudoku, which we call a joint-groups Sudoku. We
describe this Sudoku type in detail and also discuss the corresponding preference profiles for
men and women.
Now we provide a more detailed description of the paper.
Specifically, Section 2 is devoted to definitions and background related to the stable
marriage problem and Sudokus.
Section 3 translates SMP into the language of Sudoku. We explain how to draw a
preference profile in a Sudoku grid. We also show how to find blocking pairs and explain the
Gale-Shapley algorithm in terms of Sudoku.
Section 4 translates Sudokus into the language of SMP. We define non-overlapping prefer-
ence profiles, which are profiles that could correspond to different digits in a complete Sudoku
grid. We explain what it means to solve a Sudoku puzzle for these preference profiles.
We start Section 5 with defining pseudo-Latin profiles introduced in [4]. We generalize
this notion and introduce mutually Latin profiles. These are the profiles where the men’s
and the women’s preference matrices are Latin squares. We also introduce disjoint profiles
inspired by disjoint-groups Sudokus.
Section 6 introduces a new Sudoku type called joint-groups Sudoku. The profiles corre-
sponding to this Sudoku are called joint profiles. We show that a joint profile is uniquely
defined by a key function. We also show that joint profiles are mutually Latin profiles.
In addition, we classify joint profiles for n = 3, and discuss some properties of their sta-
ble matchings. Finally, we show that joint-groups Sudokus exist and give two joint-groups
Sudoku puzzles for readers to solve.
In Section 7 we apply all the theory we developed to completely analyze the case of n = 2.
Section 8 contains answers to the puzzles from Section 6.
2 Definitions
In the stable matching problem we study in this paper, we have n men and n women who
prefer getting married over being single. As is traditional in this problem, we assume that
men only marry women and vice versa. Each person ranks people of the other gender without
ties. We call these 2n sets of preferences a preference profile.
2
Once the preference profile is set, people are matched into marriages. We call the set of
all these marriages unstable if there is a man M and woman W such that they prefer each
other to their spouses, and stable if no such man/woman pair exists. In an unstable set of
marriages, the pair M and W described above is called a blocking pair or a rogue couple. By
definition, a set of marriages without a blocking pair is stable.
There exist algorithms to find a stable matching given a preference profile. The first
and most famous is the Gale-Shapley algorithm [1] (also known as the deferred acceptance
algorithm), which involves a number of rounds:
• In the first round, each man proposes to the woman he prefers most, and then each
woman replies “maybe” to her most preferred suitor and “no” to all other suitors. She
is then provisionally “engaged” to the suitor she most prefers so far, and that suitor is
likewise provisionally engaged to her.
• In each subsequent round, first each unengaged man proposes to the most-preferred
woman to whom he has not yet proposed (regardless of whether the woman is already
engaged), and then each woman replies “maybe” if she is currently not engaged or if
she prefers this man over her current provisional partner (in this case, she rejects her
current provisional partner who becomes unengaged).
• This process is repeated until everyone is engaged. At this point, all engaged couples
form a stable matching. They can start planning their weddings.
For n men and n women, the matching algorithm takes at most n2 − n + 1 rounds and
terminates in a stable matching [1].
Let S be the set of all possible stable matchings. We call man M a valid partner of
woman W if there exists some stable matching s ∈ S where they are matched. A matching
is called man-optimal if each man receives his best valid partner, and man-pessimal if each
man receives his worst valid partner.
The Gale-Shapley algorithm, where men are proposing, results in a man-optimal stable
matching [2]. If a matching is man-optimal, then it is also woman-pessimal [2]. It follows
that if the men-proposing and women-proposing algorithms end in the same matching, then
this is the only stable matching.
3
The Latin marriage problem is interesting because pseudo-Latin profiles tend to produce
a lot of stable matchings. Sequence A069124 in the OEIS [5] describes the number of possible
stable matchings in a pseudo-Latin profile with n men and n women. It starts as
1, 2, 3, 10, 12, 32, 42, 268, 288, 656, 924, 4360, 3816, 11336, . . . .
This sequence counts the number of stable matchings for special types of profiles, thus
providing a lower bound in the number of stable matchings for any profile.
(n!)2n
since each person of one gender can rank all the people of the opposite gender in n! ways.
The corresponding sequence is sequence A185141 in the OEIS [5]. The sequence starts as
follows, where the first term corresponds to n = 1:
In the OEIS, this sequence is defined as “a(n) is the number of ‘templates,’ or ways of
placing a single digit within an n2 by n2 Sudoku puzzle so that all rows, columns, and n by
n blocks have exactly one copy of the digit.”
This connection between preference profiles and Sudokus motivated this paper.
2.3 Sudoku
A Sudoku grid is a 9 by 9 square that is divided into three vertical stacks, and 3 horizontal
bands. A 3 by 3 square at the intersection of a stack and a band is called a region, a block
or a box. A small 1 by 1 square is called a cell.
We can expand these definitions to n2 by n2 Sudokus, where the standard Sudoku cor-
responds to the case n = 3. The number of completed Sudokus of size n2 by n2 is sequence
A107739 in the OEIS [5] database, which starts as follows with the first term corresponding
to n = 0:
1, 1, 288, 6670903752021072936960, . . . .
4
By definition, the egalitarian cost of every pair of people in a pseudo-Latin profile is n+1.
Therefore, the egalitarian cost of any pseudo-Latin stable matching is n(n + 1).
Note that the minimum possible egalitarian cost for a pair of people is 1 + 1 = 2, because
at best, two people can rank each other first. In this scenario, unless they are married to
each other, they will be a blocking pair. For this reason, we call such a pair a soulmate
pair, or simply soulmates. When a soulmate pair exists, we can marry them to one another
and then reduce the situation to the stable marriage problem with 2n − 2 people. Since the
minimum egalitarian cost is 2, the egalitarian cost of an egalitarian matching (for n men
and n women) is at least 2n. The cost 2n is achievable when all people can be divided into
soulmate pairs.
Now, suppose we have two people that rank each other as n: the worst they can. We
call such a pair a hell-pair. If they are married in a stable matching, then they are called a
hell-couple. Such a pair has an egalitarian cost of 2n. It follows that such a pair can’t happen
in a pseudo-Latin preference profile. Also, a stable matching can’t contain two hell-couples
because two people of opposite genders in different hell-couples form a blocking pair.
In some respect, the opposite notion to soulmates is not a hell-pair, but rather the
outcasts. We call two people outcasts if they are ranked n by everyone else. In a stable
matching, two outcasts have to be matched with each other. Note that the outcasts might
be soulmates, hell-couples, or anything in between.
5
women. We number rows in a band from top to bottom and columns in a stack from left to
right.
Next, to fill in the cells, we consider an n by n box formed by the intersection of a stack
and a band representing a pair of people, say man M and woman W . An entry in the box
represents how M and W rank each other; the entry in row i and column j of the box means
that woman W ranks man M as i and man M ranks woman W as j.
A preference profile marks one cell in each box, and corresponds to how each man-woman
pair rank each other. In our diagrams, we use blue circles to mark such cells. There is exactly
one cell marked in each row or column. Indeed, a column corresponds to man M and rank
number. There is exactly one person with a given rank by a given man. A similar argument
works for a row. This means a preference profile corresponds to one digit filled in a Sudoku
grid.
3.3 A 2 by 2 example
We say that A and B are men, and C and D are women. Suppose for example, our preference
profile looks like this: A prefers C over D, B prefers D over C, and both C and D prefer B
over A. Figure 1 demonstrates how the grid is filled in.
In this example, B and D are soulmates, and in every stable matching, they end up
together. It follows that A and C have to be a couple in every stable matching. Thus, this
profile allows only one stable matching.
The matrixof how women rank men is in this case 22 11 . The matrix of how men rank
women is 12 21 . Here we show the ranking matrix and the ranking tally matrix for this
6
example:
(2, 1) (1, 2) 1 1
and .
(2, 2) (1, 1) 1 1
The tally matrix with all ones is special. Such profiles are called disjoint profiles, and we
study them in Section 5.2.
To summarize, the blocking pair corresponds to the circle in the Sudoku which is to the
left of the circle for the man’s current partner and above the circle for the woman’s current
partner.
7
Then we repeat the following steps until every stack has a red circle. If a stack has a red
circle, meaning the corresponding man is engaged, then the stack is unchanged. If a stack
doesn’t have a red circle, then we find the left-most circle that has never been recolored and
color it green. In other words, unengaged men propose to their next best choice.
Now we go to bands (women’s turn). The bands without green circles (the bands without
new proposals) are unchanged. If a band has a green circle, then we color the top-most non-
blue circle red, and reset other circles to blue. In the end, we have one red circle in each
band and stack corresponding to a stable matching.
A B C D
1234123412341234
A B C D
1234123412341234
A B C D
1234123412341234
1 1 1
2 2 2
E 3 E 3 E 3
4 4 4
1 1 1
2 2 2
F 3
4
F 3
4
F 3
4
1 1 1
2 2 2
G 3 G 3 G 3
4 4 4
1 1 1
2 2 2
H 3 H 3 H 3
4 4 4
Preference Profile Round 1 End of Round 1
A B C D
1234123412341234
A B C D
1234123412341234
A B C D
1234123412341234
1 1 1
2 2 2
E 3 E 3 E 3
4 4 4
1 1 1
2 2 2
F 3
4
F 3
4
F 3
4
1 1 1
2 2 2
G 3 G 3 G 3
4 4 4
1 1 1
2 2 2
H 3 H 3 H 3
4 4 4
Round 2 End of Round 2 Round 3
A B C D
1234123412341234
A B C D
1234123412341234
A B C D
1234123412341234
1 1 1
2 2 2
E 3 E 3 E 3
4 4 4
1 1 1
2 2 2
F 3
4
F 3
4
F 3
4
1 1 1
2 2 2
G 3 G 3 G 3
4 4 4
1 1 1
2 2 2
H 3 H 3 H 3
4 4 4
End of Round 3 Round 4 End of Round 4
8
from the entry for their preferences to the top-left corner plus 2. Note that the Manhattan
distance between two cells in a grid is the smallest number of steps from one cell to the
other. In this case, an allowed step is a move from a cell to an orthogonally-adjacent cell.
The egalitarian cost of a cell in a block could also be determined by the anti-diagonal it is
in since the anti-diagonal is equidistant from the top-left cell.
The egalitarian cost of a stable matching is 2n plus the sum of the Manhattan distances
between each red circle (circles correspond to couples in the matching) and the top-left corner
of the box.
9
4.4 Maximum number of clues
What is the maximum number of clues that do not guarantee a unique solution? One can
see that if the puzzle is missing one entry of a given digit, this digit has a unique placement.
If the missing clues are of the same digit, the solution is unique too. By combining these
statements, we see that if not more than one digit has more than one entry missing, we can
finish the puzzle uniquely. It follows that if there are 80, 79, or 78 clues given, the solution
is unique. However, it is possible to construct a Sudoku puzzle with 77 clues given and two
solutions.
By extending this example to any n, we see that n4 − 3 clues guarantee a unique solution
to a puzzle if the solution exists. Correspondingly, we see that n4 − 3 rankings are necessary
to guarantee that one can reconstruct n2 unique non-overlapping preference profiles.
5 Special profiles
5.1 Generalized pseudo-Latin profiles
Recall that pseudo-Latin profiles [4] are profiles where the egalitarian cost of each pair of
people is n + 1. In such profiles, two men can’t give the same rank to the same woman;
otherwise, she would have ranked both men the same. As a consequence, the matrix of men’s
preferences forms a Latin square. Similarly, the matrix of women’s preferences forms a Latin
square.
It is natural to drop the request that the egalitarian cost for every pair of people is n + 1
while leaving the requirement that both the men’s profiles and the women’s profiles form a
Latin square. We call such profiles mutually Latin profiles.
The Gale-Shapley algorithm, when applied on a mutually Latin profile, will always take
exactly one round. Because every man has a different ranking for each woman, all the men
propose to different women in the first round. However, the number of stable matchings
can vary from one (when there are n pairs of soulmates) to relatively large when it is a
pseudo-Latin profile.
For n > 2, we can’t have outcasts in a mutually Latin profile, as we have exactly one man
who ranks a given woman as n and vice versa. But we can have soulmates and hell-pairs.
We can even have n pairs of soulmates and n hell-pairs.
10
the ranking tally matrix consists of all ones. We call such a profile a disjoint profile. In
particular, each disjoint profile has exactly one pair of soulmates and one hell-pair.
Figure 4 shows an example of a disjoint-groups Sudoku. Coincidentally, this is the lexi-
cographically earliest complete Sudoku grid, read by rows.
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 1 4 3 6 5 8 9 7
3 6 5 8 9 7 2 1 4
8 9 7 2 1 4 3 6 5
5 3 1 6 4 2 9 7 8
6 4 2 9 7 8 5 3 1
9 7 8 5 3 1 6 4 2
For another example of a disjoint profile, we consider a profile where all men rank everyone
the same way. To prove that such a profile is disjoint, consider the mutual ranking (i, j).
There is exactly one woman that is ranked i (by every man). And she ranks precisely one
man as j. Thus, a pair (i, j) appears exactly once in the ranking.
We can have a Sudoku consisting of profiles where all men rank everyone the same way.
An example of such a profile is shown in Figure 5.
How can we see in a Sudoku that all men have the same preferences? For simplicity, let’s
assume we are talking about profile 1. In each band, all the ones must all be in the same
column in their box. Now we connect such profiles to stable matchings.
Proposition 1. If all the people of the same gender have the same list of preferences, there
is only one stable matching.
Proof. Without loss of generality, we assume that men have the same preferences. We
continue by induction. If n = 1, we have only one matching possible, and it is stable.
Suppose for n ≤ k the statement is true. Consider n = k + 1. The pair of people that
consists of the most desirable woman and her first choice are soulmates. They are married
in any stable matching. If we remove them from consideration, we can use induction.
Consider the lexicographically earliest Sudoku in Figure 4. For every digit, the men have
the same preferences. It follows that each profile has exactly 1 stable matching. By shuffling
the digits, we can get 9! DG Sudokus where each profile has exactly 1 stable matching. One
of these Sudokus is the lexicographically last Sudoku: it can be written out by replacing
digit x with digit 10 − x in the lexicographically earliest Sudoku.
11
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8
Figure 5: An example of a DG Sudoku, where in each corresponding profile all men rank
everyone the same way.
Each disjoint profile has exactly one pair of soulmates. It means that the number of
stable matchings for such a profile can’t exceed the maximum number of possible matchings
for n − 1 men and women. For example, when n = 3, each disjoint profile can’t have more
than 2 stable matchings. In the examples above (Figures 4 and 5), we have DG Sudokus
such that all of the profiles have exactly one stable matching. Figure 6 shows an example
of a DG Sudoku where two of the profiles, corresponding to digits 1 and 3, have two stable
matchings. The other profiles have one stable matching.
1 4 7 6 9 3 8 2 5
2 5 8 4 7 1 9 3 6
3 6 9 5 8 2 7 1 4
4 7 2 3 6 9 5 8 1
5 8 3 1 4 7 6 9 2
6 9 1 2 5 8 4 7 3
7 3 4 9 1 6 2 5 8
8 1 5 7 2 4 3 6 9
9 2 6 8 3 5 1 4 7
Figure 6: An example of a DG Sudoku where some of the profiles have two stable matchings.
What happens if we combine disjoint profiles with mutually Latin profiles? In mutually
Latin profiles men’s and women’s preferences form Latin squares. By definition of disjoint
12
profiles, when these squares are superimposed, the ordered paired entries in the cells of the
square are all distinct. This is exactly the definition of the mutually orthogonal or Graeco-
Latin squares.
Mutually-orthogonal squares are used to build magic squares. Thus, we can use the men’s
and women’s preferences in a disjoint mutually Latin profile to build a magic square.
Figure 7 shows an example of a disjoint mutually Latin profile. Here are the preference
matrices for men and women in this profile:
1 2 3 1 2 3
3 1 2 and 2 3 1 .
2 3 1 3 1 2
The first man and the first woman are soulmates, so they have to be a couple in any stable
matching. For the remaining four people, both possible matchings are stable. Therefore, the
total number of stable matching for this profile is 2.
We gave an example above (where all men have the same preferences) of a disjoint profile
that is not a mutually Latin profile. An example of a mutually Latin profile that is not
disjoint exists. The following subsection discusses such an example.
13
appears in the top-left corner of a box, it has to appear in the top-left corner of n boxes. We
call such a profile a joint profile. We call a complete Sudoku with each digit forming a joint
profile a joint-groups Sudoku.
14
Proposition 4. No hell-couples can exist in a stable matching for a joint profile with n men
and n women.
Proof. Suppose there exists a stable matching containing a hell-couple for a given joint
profile. That means f (n) = n, where f is the key function. Suppose M is the man in the
couple. Because the women’s preferences form a Latin square, there exists a woman W who
ranks man M first. Then M and W form a blocking pair. This leads to a contradiction.
15
6.3 Classification of joint profiles for n = 3
For this section, we assume that n = 3. We classify joint profiles with respect to the
number of stable matchings. We look at the profiles in terms of the key functions. There
are six different key functions. The surprising fact is that all stable matchings for n = 3 are
uniform. In other words, they correspond to one entry in the tally matrix. These profiles
are represented in Figure 8 by ranking tally matrices, where the digit 3 is replaced with a
circle. Green circles show a possible mutual ranking for all couples in a stable matching. By
contrast, red circles show the impossible rankings. As we proved in Proposition 5, the red
circles for uniform matchings are the ones that have another circle to the top-left.
Suppose f (1) = 1, or in other words, (1, 1) belongs to the list of rankings. This means
that we have three pairs of soulmates and one stable matching. In this matching, all pairs
of soulmates are matched to each other. This case covers two key functions corresponding
to the two left-most matrices in Figure 8.
Suppose we have a pseudo-Latin profile, or f (i) = 4 − i. Then there are three stable
matchings. One matching marries pairs with mutual ranking (1, 3): it is woman-optimal
and man-pessimal. Similarly, there is a stable matching marrying pairs with mutual ranking
(3, 1): it is woman-pessimal and man-optimal. The third matching marries pairs with mutual
ranking (2, 2). This key function corresponds to the third matrix in Figure 8.
There are three possible key functions left, with two different stable matchings each. One
matching marries pairs with mutual ranking (1, i): it is woman-optimal and man-pessimal.
Similarly, there is a stable matching marrying pairs with mutual ranking (i, 1): it is woman-
pessimal and man-optimal. The third matching is impossible in a stable marriage. These
three key functions correspond to the last three matrices in Figure 8.
16
of band i and stack j is the same as the box in the intersection of band i + k and stack j + k,
where the band and the stack numbers are taken modulo n.
Box-cyclic Sudokus are JG Sudokus. Indeed, in such a Sudoku, each digit appears in
exactly n places inside a box. In addition, box-cyclic Sudokus are easy to build. We use this
fact in the next theorem.
Theorem 7. A joint-groups Sudoku exists for any n.
Proof. First, we arrange the integers 1 through n2 into an n by n box. We call it box B1 .
For box Bi , we take the numbers from box B1 and move them i steps to the right and i steps
down, wrapping around if necessary. Now we place box Bi into the intersection of stack j
and band j + i − 1 considered modulo n. Thus, every box appears n times: once in each
stack and once in each band.
Now we show that we get a complete Sudoku grid. Consider a number that appears at
coordinates (a, b) in box B1 . Then it appears at coordinates (a + i, b + i) modulo n in box
Bi . Each box appears once in every stack and band; therefore, the number appears once in
every row and column, as well as once in every box.
Now we show that the rules of joint-groups Sudoku are satisfied. The key function
corresponding to the integer that appears at coordinates (a, b) in box B1 is the following:
f (x) = b − a + x modulo n.
A JG Sudoku doesn’t have to be box-cyclic, as demonstrated in Figure 9.
1 4 7 2 5 8 3 6 9
8 2 5 9 3 6 7 1 4
6 9 3 4 7 1 5 8 2
3 5 8 1 6 9 2 4 7
9 1 6 7 2 4 8 3 5
4 7 2 5 8 3 6 9 1
2 6 9 3 4 7 1 5 8
7 3 4 8 1 5 9 2 6
5 8 1 6 9 2 4 7 3
Now we want to define the placement matrix for a box-cyclic Sudoku. The placement
matrix is an n by n matrix, where each element of the matrix shows n integers that appear
in the corresponding cells of the box. For example, the placement matrix for Sudoku in
Figure 9 is
123 456 789
789 123 456 .
456 789 123
17
6.5 JG Sudoku puzzles
We invented a new type of Sudoku, so we have no choice but to present some puzzles.
Figure 10 shows Sudoku puzzles, where the complete grid has to be a joint-groups Sudoku.
The puzzle on the left is easier. The puzzle on the right contains the minimum possible
number of clues: 8. This is because of the following: if there were 7 clues, then at least 2
digits wouldn’t have been given, so they could be swapped in the solution.
7 9 5
4 6 7
1 8 2
1
5
3 8
3 2
6 9
5 6 3
7 An examination of n = 2
We use the knowledge we have gained in the previous sections to completely describe the
case of n = 2.
A. Both men prefer the first woman, while both women prefer the first man.
B. Both men prefer the first woman, while the first woman prefers the first man and the
second woman prefers the second man.
C. The first man prefers the first woman, while the second man prefers the second woman;
the first woman prefers the first man, and the second woman prefers the second man.
D. The first man prefers the first woman, while the second man prefers the second woman;
the first woman prefers the second man, and the second woman prefers the first man.
18
7.1.1 Type A
The egalitarian costs of the four possible pairs are 2, 3, 3, and 4. Thus we have one pair
of soulmates and one hell-pair. Moreover, the soulmates and the hell-pair do not overlap.
The presence of soulmates means that there is exactly one stable matching, with one couple
being soulmates and the other couple being the hell-couple. The total egalitarian cost is 6.
We have four different profiles of type A as shown in Figure 11. Geometrically, we can
describe these profiles as follows. One box has soulmates, and the diagonally opposite box
has a hell-pair.
7.1.2 Type B
The egalitarian costs of the four possible pairs are 2, 3, 3, and 4. Thus we have one pair
of soulmates and one hell-pair. In addition, the soulmates and the hell-pair share a person.
The presence of soulmates means that there is exactly one stable matching, with one couple
being soulmates and the other couple having an egalitarian cost of 3. The total egalitarian
cost is 5.
We have eight different profiles of type B as shown in Figure 12. Geometrically, we can
describe them as follows: one box has soulmates, and another box in the same row or column
has a hell-pair.
7.1.3 Type C
The egalitarian costs of the four possible pairs are 2, 2, 4, and 4. As soulmate pairs can’t
overlap, the people can be divided into two soulmate pairs or two hell-pairs. The presence
of soulmates means that there is exactly one stable matching, in which both couples are
soulmates, and the total egalitarian cost is 4.
We have two possibilities of type C as shown in Figure 13. Geometrically, the two pairs
of soulmates are in opposite boxes, and the two hell-pairs are in opposite boxes.
7.1.4 Type D
The egalitarian costs of the four possible pairs are 3, 3, 3, and 3. There are no soulmates
and no hell-pairs. As the only possible mutual egalitarian cost for pairs is n + 1, this type is
19
Figure 12: Profiles of type B.
a pseudo-Latin profile. There are two possible stable matchings with a total egalitarian cost
of 6.
We have two possibilities of type D as shown in Figure 14. Geometrically, there are no
entries in the top-left corner or bottom right corner of each box.
20
7.1.5 Summary
We summarize the results in Table 1. Types A and B are disjoint profiles because each of the
1 1
possible mutual rankings is used once, so both of their ranking tally matrices are .
1 1
Types C and D are joint profiles because C has the mutual rankings (1, 1) and (2, 2), and
D
hasthe mutual
rankings (1, 2) and (2, 1). The ranking tally matrices of C and D are
2 0 0 2
and respectively. In addition, type D is a pseudo-Latin profile because the
0 2 2 0
egalitarian cost of each pair is 3.
Table 1: Summary.
7.2 Symmetries
It is interesting to compare profile symmetries with geometric symmetries.
If we reflect a picture across the main diagonal, we get a picture of the same type. This
is because such an operation corresponds to swapping men and women.
The reflection with respect to the middle vertical line corresponds to changing the num-
bering of men. Namely, man x is swapped with man n + 1 − x. The women’s preferences are
reversed too: the man ranked x gets new ranking n + 1 − x. We can describe the reflection
with respect to the middle horizontal line in a similar manner.
For types A and B, if we reflect a profile across the middle horizontal line or the middle
vertical line, we get a profile of the same type, but types C and D swap with each other.
We see that profile symmetries are very different from geometric symmetries.
21
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2
2 1 4 3 2 3 4 1 4 1 2 3 4 3 2 1
4 3 2 1 4 1 2 3 2 3 4 1 2 1 4 3
1 2 3 4 1 2 3 4
3 4 2 1 3 4 2 1
2 1 4 3 4 3 1 2
4 3 1 2 2 1 4 3
Figure 15: Sudokus with the second line 3412 and 3421.
Figure 16 shows 2 Sudokus with the second line 4312 and 4 Sudokus with the second line
4321.
1 2 3 4 1 2 3 4
4 3 1 2 4 3 1 2
2 1 4 3 3 4 2 1
3 4 2 1 2 1 4 3
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1
2 1 4 3 2 4 1 3 3 1 4 2 3 4 1 2
3 4 1 2 3 1 4 2 2 4 1 3 2 1 4 3
Figure 16: Sudokus with the second line 4312 and 4321.
The Sudokus, in order, have the following sets of profile types: AAAA, BABA, ABAB,
BBBB, BBAA, CDBB, AABB, BBCD, BBBB, CBBD, BDCB, CDCD. There are two BBBB
types, but only one for each of the rest. In all 12 of the Sudokus, there are 12 A’s, 24 B’s, 6
C’s, and 6 D’s. One can notice that each individual profile appears in exactly 3 of the twelve
2 by 2 Sudokus.
If we order each set of profile types alphabetically, we get the following possibilities.
There is one AAAA, four AABBs, two BBBBs, four BBCDs, and one CCDD. We created
22
this list of Sudokus by trying all possibilities. Now, we will explain why these are the only
cases.
1. There are four soulmate pairs and four hell-pairs in each complete grid; so, on average,
every profile participating in a Sudoku has one of each. Profiles of types A and B have
one of each. Profiles of type C have two of each; profiles of type D have none. It follows
that we need the same number of profiles of types C and D in a grid to compensate
each other.
2. Every profile of type A overlaps with any profile of type C or D, so A can never be in
the same Sudoku as C or D. This explains why any Sudoku with A can only have A’s
or B’s.
3. Each A profile marks either 0 or 2 corners of the Sudoku grid. Each profile of any
other type has exactly 1 corner marked. Thus, we need an even number of profiles
other than A and consequently an even number of A’s.
These three facts taken together show why the only possible Sudokus are AAAA, AABB,
BBBB, BBCD, CCDD. The first three types are DG Sudokus, the fifth type is JG Sudoku,
and the fourth type is neither. Indeed, the Sudokus can only be disjoint-groups if the profiles
are all A’s and B’s, or joint-groups Sudokus if their profiles are all C’s and D’s.
The picture of the JG Sudoku is in Figure 17.
1 2 3 4
4 3 2 1
3 4 1 2
2 1 4 3
This is the only JG Sudoku for n = 2 up to relabeling the digits. Notice that this Sudoku
has two pairs of identical boxes. The reason is the following: consider the position of digit 1
within the top-left box. There has to be another digit 1 in the exact location relative to its
box, but it can’t be in the top-right or bottom-left box. So, it has to be in the bottom-right
box. This is true for any digit in the top-left box; thus, the bottom-right box has to be a
copy of the top-left box. Similarly, the bottom-left and top-right boxes are copies of each
other. Thus, all JG Sudokus for n = 2 are box-cyclic.
The placement matrix for this Sudoku is
13 24
.
24 13
23
Profiles 1 and 3 are mirror profiles, and profiles 2 and 4 are pseudo-Latin profiles.
8 Answers
Figure 18 shows the answers to the JG Sudoku puzzles in Figure 10 with the given clues
highlighted in green.
1 4 2 3 5 8 7 9 6 1 9 7 2 8 6 5 3 4
6 3 5 2 7 9 8 1 4 6 2 8 3 4 5 7 1 9
9 8 7 4 6 1 5 2 3 4 5 3 9 7 1 8 6 2
7 5 8 1 9 6 3 4 2 5 3 4 1 9 7 2 8 6
2 1 9 8 3 4 6 7 5 7 1 9 6 2 8 3 4 5
4 6 3 5 2 7 9 8 1 8 6 2 4 5 3 9 7 1
3 9 6 7 4 2 1 5 8 2 8 6 5 3 4 1 9 7
8 7 4 6 1 5 2 3 9 3 4 5 7 1 9 6 2 8
5 2 1 9 8 3 4 6 7 9 7 1 8 6 2 4 5 3
Surprisingly, the answer to the first puzzle has a cyclic placement matrix, while the
answer to the second puzzle is box-cyclic.
9 Acknowledgements
This project was done as part of MIT PRIMES STEP, a program that allows students in
grades 6 through 9 to try research in mathematics. Tanya Khovanova is the mentor of this
project. We are grateful to PRIMES STEP for this opportunity.
References
[1] D. Gale and L. S. Shapley, College Admissions and the Stability of Marriage, The
American Mathematical Monthly, Vol. 69, No. 1 (Jan., 1962), pp. 9–15.
24
[2] D. Gusfield and R. W. Irving, The Stable marriage problem: structure and algorithms,
Foundations of computing series, MIT Press (1989).
[3] J. Rosenhouse and L. Taalman, Taking Sudoku Seriously: The math behind the world’s
most popular pencil puzzle, Oxford University Press (2011).
[4] E. G. Thurber, Concerning the maximum number of stable matchings in the stable
marriage problem, Discrete Mathematics, Vol. 248, pp. 195-219, 2002.
25