What is the algorithm to generate the cards in the game "Dobble" ( known as "Spot it" in the USA )?h 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 . 
 A: 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

A: Here is a C code inspired from @karinka's answer with a different arrangement of symbols.
It works for $n$ being a prime number (2, 3, 5, 7, 11, 13, 17, ...).
Number of symbols in a given card = $n + 1$
Total number of cards = $n^2 + n + 1$
Total number of symbols = $n^2 + n + 1$
#include <stdio.h>
#include <stdlib.h>

#define PRINT(x) printf("%2d  ", (x)+1)

main() {
    int i, j, k, r = 0, n = 7;

    // first card
    printf ("Card %2d:  ", ++r);
    for (i = 0; i <= n; i++) {
        PRINT (i);
    }
    printf ("\n");

    // n following cards
    for (j = 0; j < n; j++) {
        printf ("Card %2d:  ", ++r);
        PRINT (0);
        for (k = 0; k < n; k++) {
            PRINT (n+1 + n*j + k);
        }
        printf ("\n");
    }

    // n*n following cards
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            printf ("Card %2d:  ", ++r);
            PRINT (i+1);
            for (k = 0; k < n; k++) {
                PRINT (n+1 + n*k + (i*k+j)%n); // Good for n = prime number
            }
            printf ("\n");
        }
    }
}

Example output with $n = 3$:
Card  1:   1   2   3   4
Card  2:   1   5   6   7
Card  3:   1   8   9  10
Card  4:   1  11  12  13
Card  5:   2   5   8  11
Card  6:   2   6   9  12
Card  7:   2   7  10  13
Card  8:   3   5   9  13
Card  9:   3   6  10  11
Card 10:   3   7   8  12
Card 11:   4   5  10  12
Card 12:   4   6   8  13
Card 13:   4   7   9  11

A: The generators submitted by Karinka, Urmil Karikh and Uwe are working nicely. However, original answer aimed at understanding the algorithm. The theory behind all three generators are in (See Paige L.J., Wexler Ch., A Canonical Form for Incidence Matrices of Projective Planes...., In Portugalie Mathematica, vol 12, fasc 3, 1953). It is generating Incidence matrix for projective plane of $q$th order in the normal form ($q=N-1$). Every row of incidence matrix corresponds to one card and column indexes where there are ones in the matrix, correspond to symbol on the card. Permutation Matrices, marked in the article as $C_{ij}$ are generated by cycling the identity matrix column-wise by $(i-1)(j-1) \mod q$ rows. This works only if $q$ is prime number, hence no divisors of zero exist in Galois field $GF(q)$. For $q$ not being prime, but only prime power, these permutation matrices $C_{ij}$ would have to be generated another way (i.e. neither addition nor multiplication groups of $GF(q)$ are not ordinary multiplication or addition, it has to be constructed using irreducible polynomials). So, above algorithms would not work for $q$ equal to $4$, $8$ or $9$.  Anyway, from this matrix, you can nicely see that the two line (cards) has exactly one point (symbol) in common and vice-versa. Also, you can see that one symbol is on exactly $N$ cards and one card has exactly $N$ symbols (assuming that all 57 cards of Dobble would be printed and not only 55).
A: 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;
}

A: @Karinka's answer in python:
def dobble(n):
    cards = []
    for i in range(n):
        for j in range(n):
            cards.append([(i*k + j) % n * n + k for k in range(n)] + [n*n + i])
    for i in range(n):
        cards.append([j * n + i for j in range(n)] + [n*n + n])
    cards.append([n * n + i for i in range(n+1)])
    return cards

from itertools import combinations
for card0, card1 in combinations(dobble(7), 2):
    assert len(set(card0) & set(card1)) == 1
```

A: 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)
    }
}

A: Here is VBA code inspired from @karinka's and @Urmil Parikh answers but using an arrangement of symbols to match answers from @Urmil Parikh, @Uwe, and @Will Jagy.
You can swap the commented lines to print letters, though they won't match the pattern from the original question.
I realize there isn't anything new in my answer but I wanted to convert it to VBA so I could try out the code in an environment I have on hand, Excel.  I'm hoping this can help someone else.
I don't quite grasp the comments about n being a prime number.  This algorithm works when n is 4 or 8 (meaning 5 or 9 symbols per card).
Public Sub Generate()
' This will generate unique cards similar to "Spot it!" or "Dobble".

    Dim i, j, k, n, s, r

' How many symbols are on each card?
' Valid numbers are 3, 4, 6, 8, 12.  5, 7, and 11 will not generate correctly.
' If s is 5, cards 6 and 14 will match more than one card.
' If s is 7, cards 8, 20, and 26 will match more than one card for numbers 8, 20, 32
s = 4

    Debug.Print (s * s) - s + 1 & " unique cards will be generated with " & s & " symbols per card."

    n = s - 1 ' Reduce by 1 since all calcs are base 0.  n should be a prime number.

    Debug.Print "n=" & n

    '--- First card
    r = 1
    Debug.Print "Card " & r & ": ",
    For i = 0 To n
        Debug.Print i + 1;
        'Debug.Print Chr(i + 65), ' Alternative to print letters
    Next
    Debug.Print

    '--- N following cards
    For i = 0 To n - 1
        r = r + 1
        Debug.Print "Card " & r & ": ",
        Debug.Print 1;
        'Debug.Print "A",
        For j = 0 To n - 1
            Debug.Print n + 1 + (n * i) + j + 1;
            'Debug.Print Chr(n + 1 + (n * i) + j + 65), ' Alternative to print letters
        Next
        Debug.Print
    Next

    '--- N*N following cards
    For i = 0 To n - 1
        For j = 0 To n - 1
            r = r + 1
            Debug.Print "Card " & r & ": ",
            Debug.Print i + 2;
            'Debug.Print Chr(i + 66),
            For k = 0 To n - 1
                Debug.Print (n + 1) + (n * k) + ((i * k + j) Mod n) + 1;
                'Debug.Print Chr((n + 1) + (n * k) + ((i * k + j) Mod n) + 65), ' Alternative to print letters
            Next
            Debug.Print
        Next
    Next

End Sub

Sample output
13 unique cards will be generated with 4 symbols per card.
Card 1:        1  2  3  4 
Card 2:        1  5  6  7 
Card 3:        1  8  9  10 
Card 4:        1  11  12  13 
Card 5:        2  5  8  11 
Card 6:        2  6  9  12 
Card 7:        2  7  10  13 
Card 8:        3  5  9  13 
Card 9:        3  6  10  11 
Card 10:       3  7  8  12 
Card 11:       4  5  10  12 
Card 12:       4  6  8  13 
Card 13:       4  7  9  11 

7 unique cards will be generated with 3 symbols per card.
Card 1:       A             B             C             
Card 2:       A             D             E             
Card 3:       A             F             G             
Card 4:       B             D             F             
Card 5:       B             E             G             
Card 6:       C             D             G             
Card 7:       C             E             F          

vba excel-vba
A: 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$.
