There's a fun pattern matching game called Dobble. As with many good games, it's based on a straightforward idea. There are cards (which happen to be circular, which means that the cards don't have a fixed orientation). Each card has symbols on it, drawn from a collection of symbols overall. The symbols on the cards are chosen in such a way that each pair of cards has exactly one symbol in common. The game is basically to spot the matching symbol on a given pair of cards1.
1There are different wrappings around this gameplay to add a bit of variation, and there's an extra wriggle in that the symbols may appear at different sizes and in different orientations.
As well as enjoying playing it, I've been convinced that there's something mathematical in there. Not particularly in the game play itself, but somewhere in the cards. There ought to be some relationship between the number of cards, number of symbols, and number of symbols per card.
2 Finding the Formula
I'll admit, there were a couple of reasons why I didn't find a formula very quickly. One is that it doesn't use my area of expertise. Another is that I wasn't thinking about it very hard. Lastly, I got a bit caught up in edge cases.
The edge cases are important to deal with. One way to artificially inflate the complexity is to add unique symbols to each card. This increases the number of symbols and symbols per card but without increasing the mathematical complexity of the set-up2. The other edge case is when there is a single symbol, then there can be any number of cards with that single symbol on it. This would make for a rather dull game!
2It increases the complexity of the game because the extra symbols add distractions, but that's not what we're interested in here.
So let's call a set of cards and symbols reduced if all symbols appear in at least two cards and all cards are unique. In particular, this means that if we only have one symbol then we only have one card.
3 The Junior Game
One thing mathematicians like to do when studying a problem is to consider simpler cases of it. So let's simplify our game. Choosing the right simplification is an art in itself, a little experimentation lead me to decide on symbols per card3. So we start with a pack with symbols per card and assume that it is reduced.
3Three or two symbols per card is too simple, five introduces extra complications, and while six is again more straightforward it's getting close to the original of eight.
Pick a card, any card4. We'll call this the base card. We're assuming four symbols per card, and it's clearly not important what those symbols actually are, so we'll take these as , , , and .
Each other card in the deck has exactly one symbol in common with the base card, so split the deck according to the symbols on the base card. This forms sets of cards (we're tacitly using the assumption that our pack is reduced here to deduce that the sets are not empty).
Let's look at one of these sets, say . Each card in this set has the same symbol, , in common with the base card and therefore with each other. All the other symbols on the cards in this set must therefore be unique amongst these cards. As we've accounted for one symbol on each card, this leaves symbols per card. Let's use letters for these symbols. We don't know how many cards there are, but the first few would look like the following, wherein each row is a card:
As we have at least two symbols per card, in particular on the base card, there is another pile of cards sharing one of the other symbols on the base card. Let's take .
Take a card from this second set. It must share a symbol in common with each card from our first pile. That can't be the because then it would have two symbols in common with the base card ( and ). So it must have one of the other symbols from each card in the first pile.
By looking at the first card in the set, our new card must have one of , , or on it. Let's assume5 that it is . By looking at the second card, our new card must have one of , , or . Again, wlog, let's assume . From the third card, we assume . At this point our new card looks like . The crucial point is that this is four symbols and so our card is now full.
5There's a classic mathematical phrase in use here: “without loss of generality", or “wlog", meaning that this assumption does not restrict our argument in any way.
In particular, there's no room for a symbol in common with the fourth card in our first set, , and so that card cannot exist. Our first set, therefore, can have at most cards in it:
There was clearly nothing special about here so this argument holds for each of the sets. Thus each set has at most cards in it and so the number of cards in the deck is at most (the is the base card). Note that the significance of the here is that it is the number of symbols on a card other than the symbol in common with the base card. Thus here is “".
This is an upper bound on the number of cards. We haven't shown that there is a deck with that number of cards.
There's a “without loss of generality" argument that says that if the cards are as above, then we can assume that the cards are:
To put this another way, if we make a grid of the extra symbols:
then the cards are the rows and the cards are the columns. For the and cards we need to find sets of three symbols from this grid with the property that each set has one from each row and one from each column. This will ensure a one-symbol overlap with each card from the and piles. In addition, the sets must be disjoint from each other (as these already share the symbol), and similarly for the sets.
This is possible. For , we start with the downward diagonal, . The disjoint property then forces us to take and . For , we start with the upward diagonal, , which forces and .
We should check that this works, but we can do this by just “look and see". The full list of cards is then:
4 The General Story
Let's see what of the above generalises. We start with a pack with symbols per card. Exactly as above, we pick a base card and split the rest of the pack accordingly. The same argument runs through to show that there can be at most cards in each of the resulting piles. This gives at the maximum number of cards:
Similarly, for symbols if one pile is maximal (has cards in it) then the number of symbols is:
The part that is trickier is to show that these upper bounds are achievable.
In the following, is going to play a bigger role than so we'll give that a symbol of its own. For not completely arbitrary reasons, we'll call it . So .
The clue comes from laying out the grids in a particular fashion. In our simpler example, let us copy the last two rows of the grid at the start:
The cards were , , and . The first of these, , we said was the downward diagonal but now we can see that the others are similar downward lines parallel to the first. Similarly, the cards are the upward diagonal and the lines parallel to it.
Once the word “line" has been said, more ideas should follow. We can draw all of the cards as lines on the above grid, resulting in Figure 1.
Drawing lines is more than just a convenient illustration. Cards in the same pile should have empty intersection while cards in different piles should intersect in a single symbol. If we replace “card" with “line" and “symbol" with “point" this translates to: lines in the same pile should not intersect while lines in different piles should intersect in a single point. Or in more geometrical language, lines in the same pile should be parallel while lines in different piles should not be parallel.
Let's make this more precise. We place the symbols on the cartesian plane at the points with integer coordinates, starting at . We then repeat the pattern vertically up the plane. So as we go up, every th symbol is the same. We shall represent the symbols as dots, relying on their coordinates to tell us when two points represent the same symbol. The result is shown in Figure 2.
Now we usually think of lines in terms of gradient and –intercept, so we'll do the same here. Parallel lines have the same gradient, so the cards in the same pile must differ by –intercept. Fortunately, we have unique possibilities for the –intercepts, starting at and going up to (but no more, as the symbol at is the same as that at ).
Looking at the possible gradients, let's start with the lines through the origin. The gradient then says which symbol in the second column (with –coordinate ) lies on this line. We could experiment with strange gradients, but again we have some obvious choices: the numbers to .
So we have gradients to and –intercepts to . This doesn't quite give enough as we need one more set of lines, but for these we take the vertical lines. Figure 3 shows the resulting picture.
Finally, to get the symbols on the cards we take the symbols that lie on the line. For all but the vertical lines, these are the symbols corresponding to the actual points they pass through. For the vertical lines, we have to remember that the symbols repeat and so once we have collected the first symbols we can stop.
This all looks good: our knowledge of lines says that the families of parallel lines don't intersect, and non-parallel lines intersect in a single point.
However, this ignores the fact that the symbols repeat and it is the symbols that count, not the points. In the example we've been using then actually all is fine, but if we increase to we run into problems. Figure 4 shows the problem.
The green lines have gradient , with the base green line being . This starts at . It passes through the point , which is the same symbol as . This is a problem because the points and lie on the same horizontal line so the line has two symbols in common with that horizontal line.
It turns out that the case can be fixed, but cannot. In general, this strategy works as stated when is prime. When is a prime power, such as or or , then there is a variant of this strategy that works. But if has two distinct prime factors, this strategy will fail.
So is the smallest number where we don't have a proof that the maximum number of cards is achievable.
5 The Composite Case
Unfortunately, this isn't a proof that it can't be done for or or any of these numbers. It just says that the “obvious" method will fail. I don't know of a method to show that the case can't be done, as there may be some cunning way of stacking the deck6 to get the required symbols.
6Couldn't resist that one. Sorry.
But I doubt it. The reason that I doubt it is that I wrote a computer program to search for a solution and it hasn't found one.
It hasn't finished looking though. There are a lot of cases to consider and I've probably not programmed it to look as carefully as possible so it takes a long time. However, the same program found a solution for in far less time than it's spent looking for solutions for so my hunch is that no solution exists for .
6 The Wrap Around
Back to the simple cases that do work. We fix a prime number. The key is to work with modular arithmetic, which is sometimes called clock arithmetic. In short, you imagine that you are working with the numbers on a clock only instead of a traditional hr clock the dial is marked with the numbers to .
The key feature of modular arithmetic is that you “wrap around" the clock. So whenever a calculation takes you outside the region to you wrap around the clock to work out what the answer should be. For example, on a normal clock then hrs past o' clock should be o' clock but due to the “wrap around" it is the same as o' clock7. This extends to subtraction, so hrs before o' clock is o' clock. It also extends to multiplication: simply work out the multiplication as normal and then “wrap" the answer around the clock. So lots of hrs is hrs which on a hr clock is o' clock.
7The key difference to a normal clock – apart from the number of “hours" – is that o' clock is written .
On “most" clocks, this doesn't extend to division. But if the clock number is prime then division works. The key is to remember that division is “that which undoes multiplication". If you multiply by, say, and then divide by you should get back to where you started. On a hr clock then that can't be done. But on, say, a hr clock then it can. On a hr clock then multiplying by and then by gets you back where you started, as in Table 1.
This extends more generally: if, and only if, is prime then division works on a hr clock.
How can we use this? Instead of repeating our grid on the normal axes, we label the points using the numbers on a hr clock. When we work out lines, we use clock arithmetic. So with our example of , the line passes through the points , , and . The latter because when then but on the hr clock then is the same as .
Joining the points together becomes a little dubious, as there are no fractions or decimals in clock arithmetic, but it's convenient to help see which points are connected. It's worth looking at Figure 5 to see that the “lines" are as expected. The red lines are , the blue lines are , the green lines are , and the dark green lines are the vertical lines.
Our general strategy is the same as before: we define lines by with . What we need to show is that the key properties of lines carry over from normal space into this strange clock space. That is, parallel lines don't intersect and non-parallel lines intersect in a single point.
That parallel lines don't intersect is straightforward. Lines are parallel if they have the same gradient so we're asking for the intersection of and . This occurs if . The rules of algebra still apply so we can simplify this to . Thus parallel lines intersect only if they are the same line.
Now let us look at non-parallel lines, say and . Then we solve:
Now we use division and “divide" by to get:
where the fraction has to be interpreted in clock arithmetic as meaning divided by .
This shows that is unique on the clock and so there is a single intersection point.
Thus our intuition works and non-parallel lines intersect at a single point. This means that the strategy for making a deck works when is prime.
There is an adaptation of this for when is a prime power, meaning a prime number raised to some power. There's a “clock" for these situations, but it isn't the clock with numbers . For example, the clock for has four symbols and addition works like this:
Multiplication works like this:
7 To Infinity and Beyond
We're not done. We're going to extend our clocks a little more. If we take seriously the analogy between “cards" and “lines" then our geometrical picture doesn't reflect the whole story. The reason we wanted some lines to be parallel was because we had already dealt with their intersections. But in the full deck, every pair of cards intersects. So to put the full deck into a geometrical picture, we need for all lines to intersect somewhere, whether parallel or not.
The oft-heard maxim is that parallel lines meet “at infinity". As with so many such sayings, it is completely false: there is no “infinity" in ordinary geometry for parallel lines to meet at. But also as with so many such sayings, mathematicians have taken this saying and made it work.
To make parallel lines meet “at infinity" we need to add in a point “at infinity" for them to meet at. But we have to do this carefully. We can't just add one point “at infinity" and have all lines meet there because then the non-parallel lines will meet twice: once in “normal space" and once “at infinity". So we need to add a point “at infinity" for each possible gradient, including the vertical lines (whose gradient could well be said to be “infinity").
Thus the grid for should look like Figure 6.
With the points at infinity added, the line then passes through the point and vertical lines through . In addition, we get a further vertical line passing through all the points “at infinity". Our final diagram is in Figure 7.
With regard to counting, we now have symbols, but also lines ( lines of the form , “normal" vertical lines, and vertical line “at infinity"). This is no coincidence. The lines are specified by a –intercept and a gradient, which means numbers, and the symbols are specified by an –coordinate and a –coordinate, which is again numbers. The points “at infinity" fit into this story as the vertical lines. So there is a duality between points and lines, which transfers to a duality between cards and symbols.
Moreover, there are points on each line and thus points on each card. The number of cards and symbols agrees with our earlier calculation since if then
8 Back in the Game
The Dobble pack has symbols per card, which fits our pattern as is prime. However, there are only cards in the Dobble pack whereas . So if Dobble have used the correct scheme, there are two cards missing8. Rather than figure out if Dobble used the right scheme, the easiest way is to find candidates for the missing cards and observe that they work.
8It is unlikely, but possible, that there is a way to choose the symbols on the cards so that although the pack is not its maximum size then it isn't possible to simply add two cards to make it the maximum size.
Using the system of dividing the pack into piles according to a “base" card, it is possible to find the two missing cards. These are9:
9Your family might have different names for the symbols
Ice cube, cactus, T-rex, question mark, snowman, maple leaf, daisy, man.
Skull, bulb, dog, hammer, snowman, exclamation mark, eye, ladybird.
There are, though, symbols10.
10On the game instructions, they say “ symbols".
There's probably something optimal in terms of game play in having symbols per card. If you want a simpler or slightly more difficult game, Table 2 gives the number of maximum number of cards for a given number of symbols per card. Note that has to be a prime power, so and are omitted from the table.
|Symbols per||card||Pack size|
9 And Finally …
The story is fairly complete if the number of symbols on a card is one more than a prime power and you want the maximum number of cards. But there are still some questions that could be investigated.
Is it possible to find a configuration of symbols and cards with more symbols than the “maximum"?
The point here is that our “maximum" number of symbols was predicated on a certain assumption about the number of cards. If that assumption is false, is it possible to get more symbols?
What's the largest deck with symbols per card?
The largest my computer search found was , but that wasn't a full search.
For a given number of symbols per card, are there maximal configurations of cards that are not the maximum?
That is, if we have, for example, symbols per card then the maximum number of cards is . Clearly we can get a smaller deck by simply discarding cards, but there will almost certainly be other configurations with fewer than cards with the property that it is impossible to add cards to them.