What is the algorithm to generate the cards in the game "Dobble" ( known as "Spot it" in the USA )?h

27.9k Views Asked by At

In the game Dobble ( known in the USA as "Spot it" ) , there is a pack of 55 playing cards, each with 8 different symbols on them. What is remarkable ( mathematically ) is that any two cards chosen at random from the pack will have one and only one matching symbol . This spurred me on to investigating the Maths behind generating such a pack of cards, starting with much more basic examples with only 2 symbols on each card and gradually working my way up to 8 .

This has been explored extensively in the linked question "What is the Math behind the game Spot it".

What has been established is that if the number of symbols on each card is N, then the maximum number of different symbols throughout the pack is C , the maximum number of cards in a pack is also C, the number of times any given symbol is repeated throughout the pack is N, and N and C are related as follows :

C = N^2 - N + 1 [ N squared minus N plus one ]

But I still do not understand the algorithm for generating the cards from a given symbol set .

I am trying to follow the matrix generated by Don Simborg , but I just can't quite follow his formula . Even for a simple matrix with N=3 and C=7, I know what the matrix should look like , but can't seem to understand his descriptive syntax . For example in column 2, row 4, his formula suggests the symbol is the one numbered 3N-1 in the sequence of 7 symbols, but 3N-1= 8 , so which symbol should I use? Is he making an assumption that we just wrap around (subtract 7) and start counting again from the beginning of the sequence ? But this still generates the wrong symbol . I know from looking at the pattern that it should be either symbol no 4 or symbol no 5, but just can't see how this arises from his formula . If we take the 7 symbols as being the letters "A", "B", "C", "D", "E" and "F", then the matrix should be as follows below :

A B C

A D E

A F G

B D F

B E G

C D G

C E F

Can anyone help me? I've been trying to crack how to generate the symbol arrangements on the "Dobble" cards for months, and have succeeded in generating the sequence as far as N=6, C=31 but I am stuck at N=7 . I would welcome any assistance or enlightenment with this , thank you !

And if I have misunderstood Don Simborg's formula, then the error lies with me !

Here are the matrices I have found from my own trial and error :

For N=4, C=13, with a symbol set being A B C D E F G H I J K L M , the matrix is as follows :

A B C D

A E F G

A H I J

A K L M

B E H K

B F I L

B G J M

C E J L

C F H M

C G I K

D E I M

D F J K

D G H L

For N= 5, C = 21, with the symbol set : A B C D E F G H I J K L M N O P Q R S T U , the matrix is as follows :

A B C D E

A F G H I

A J K L M

A N O P Q

A R S T U

B F K N R

B G J O S

B H L P T

B I M Q U

C F J P U

C G K Q T

C H M N S

C I L O R

D F L Q S

D G M P R

D H K O U

D I J N T

E F M O T

E G L N U

E H J Q R

E I K P S

To state again, both the sets above have the remarkable quality that any two rows chosen at random will have one and only one matching symbol .

5

There are 5 best solutions below

2
On

Good thing I was able to write a program to check. the first listed failure are the lines

2     8    14    20    26    32    38
4     8    16    24    26    34    42

which overlap in the two numbers $8,26.$ Note that a projective plane of "order" $6$ is impossible. I was not $100\%$ sure that this list would amount to a projective plane, but I guess it does, therefore was doomed to failure.

I seem to have 7 symbols per card. I will need to write a computer program to compare the different cards. I found an algorithm, as I was doing this it seemed right, but maybe... Below see the $43$ cards, symbols are the numbers from $1$ to $43.$

$$ 1,2,3,4,5,6,7, $$ $$ 1,8,9,10,11,12,13,$$ $$ 1,14,15,16,17,18,19,$$ $$ 1,20,21,22,23,24,25, $$ $$ 1,26,27,28,29,30,31, $$ $$ 1,32,33,34,35,36,37, $$ $$ 1,38, 39,40,41,42,43,$$

$$ 2,8,14,20,26,32,38,$$ $$ 2,9,15,21,27,33,39,$$ $$ 2,10,16,22,28,34,40,$$ $$ 2,11,17,23,29,35,41,$$ $$ 2,12,18,24,30,36,42,$$ $$ 2,13,19,25,31,37,43,$$

$$ 3,8,15,22,29,36,43,$$ $$ 3,9,16,23,30,37,38,$$ $$ 3,10,17,24,31,32,39,$$ $$ 3,11,18,25,26,33,40,$$ $$ 3,12,19,20,27,34,41,$$ $$ 3,13,14,21,28,35,42,$$

$$ 4,8,16,24,26,34,42,$$ $$ 4,9,17,25,27,35,43,$$ $$ 4,10,18,20,28,36,38,$$ $$ 4,11,19,21,29,37,39,$$ $$ 4,12,14,22,30,32,40,$$ $$ 4,13,15,23,31,33,41,$$

$$ 5,8,17,20,29,32,41,$$ $$ 5,9,18,21,30,33,42,$$ $$ 5,10,19,22,31,34,43,$$ $$ 5,11,14,23,26,35,38,$$ $$ 5,12,15,24,27,36,39,$$ $$ 5,13,16,25,28,37,40,$$

$$ 6,8,18,22,26,36,40,$$ $$ 6,9,19,23,27,37,41,$$ $$ 6,10,14,24,28,32,42,$$ $$ 6,11,15,25,29,33,43,$$ $$ 6,12,16,20,30,34,38,$$ $$ 6,13,17,21,31,35,39,$$

$$ 7,8,19,24,29,34,39,$$ $$ 7,9,14,25,30,35,40,$$ $$ 7,10,15,20,31,36,41,$$ $$ 7,11,16,21,26,37,42,$$ $$ 7,12,17,22,27,32,43,$$ $$ 7,13,18,23,28,33,38,$$

2
On

Here is an algorithm to generate a projective plane for every N prime. It will work for N power of prime if the computation of "(I*K + J) modulus N" below is made in the correct "field".

// N*N first cards
for I = 0 to N-1
   for J = 0 to N-1
      for K = 0 to N-1
         print ((I*K + J) modulus N)*N + K
      end for
      print N*N + I
      new line
   end for
end for

// N following cards
for I = 0 to N-1
   for J = 0 to N-1
      print J*N + I
   end for
   print N*N + N
   new line
end for

// Last card
for I = 0 to N-1
   print N*N + I
end for
new line
0
On

This is How I've converted the algorithm in javascript:

"use strict"

var i, j, k var r=1 var n=7

var res = ''; res = "Card" + r + "=" for (i = 1; i<= n+1; i++) { res += " " + i } console.log(res) for (j=1; j<=n; j++) { r=r+1 res = "Card" + r + "="; res += " 1"; for (k=1; k<=n; k++) { res += " " + (n + n * (j-1) + k+1) } console.log(res) } for (i= 1; i<=n; i++) { for (j=1; j<=n; j++) { r=r+1 res = "Card" + r + "=" res += " " + (i+1) + " " for (k=1; k<= n; k++) { res += n + 2 + n * (k-1) + (((i-1) * (k-1) +j-1) % n) + " " } console.log(res) } }

7
On

These help implementing @karinka's algorithm for p = 2^2 and p = 2^3 so you can easily get 4, 5, 6, 8 and 9 symbols per card for example. 10 symbols per card is also easy (p = 3^2) but there is no finite field of order 6 or 10, so 7 and 11 symbols per card cannot be generated (unless you allow more symbols than cards).

var GF4add = [
 [0, 1, 2, 3],
 [1, 0, 3, 2],
 [2, 3, 0, 1],
 [3, 2, 1, 0]
];

var GF4mul = [
 [0, 0, 0, 0],
 [0, 1, 2, 3],
 [0, 2, 3, 1],
 [0, 3, 1, 2]
];

var GF8add = [
 [0, 1, 2, 3, 4, 5, 6, 7],
 [1, 0, 3, 2, 5, 4, 7, 6],
 [2, 3, 0, 1, 6, 7, 4, 5],
 [3, 2, 1, 0, 7, 6, 5, 4],
 [4, 5, 6, 7, 0, 1, 2, 3],
 [5, 4, 7, 6, 1, 0, 3, 2],
 [6, 7, 4, 5, 2, 3, 0, 1],
 [7, 6, 5, 4, 3, 2, 1, 0]
];

var GF8mul = [
 [0, 0, 0, 0, 0, 0, 0, 0],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 2, 4, 6, 5, 7, 1, 3],
 [0, 3, 6, 5, 1, 2, 7, 4],
 [0, 4, 5, 1, 7, 3, 2, 6],
 [0, 5, 7, 2, 3, 6, 4, 1],
 [0, 6, 1, 7, 2, 4, 3, 5],
 [0, 7, 3, 4, 6, 1, 5, 2]
];

function mul(a, b, n)
{
    if (n == 4)
        return GF4mul[a][b];
    else if (n == 8)
        return GF8mul[a][b];
    else
        return (a * b) % n;
}

function add(a, b, n)
{
    if (n == 4)
        return GF4add[a][b];
    else if (n == 8)
        return GF8add[a][b];
    else
        return (a + b) % n;
}
11
On

Yesterday, I played the card game "Spot It" with my family and was facinated by the maths behind it. After working with my wife for a couple hours, we discovered the method to generate the cards. The method is now illustated using $8$ symbols per card.

Creating $49$ ($= 7$ sets of $7$) required cards:

Creating another set of $7$ using the matrix transpose:

the $57$th card:

The above method of construction can deal any number of symbols on the cards. It also shows that the maximum number of cards that meet the rules of the game is $57$, i.e. the same as the number of different symbols.

The general formula for the maximum number of cards with n symbols on each card satisfying the rules of the game is $(n-1)^2 + n$.