Generating "Dobble"-like cards

Contact: michal (at) molhanec (dot) net
Homepage: http://molhanec.net/

Note that the name "Dobble" and the game itself is copyrighted, trademarked etc. by the original authors. That means that you cannot use the name or generated cards freely and please contact original game authors before any usage.

For some time I was thinking about how to generate "Dobble"-like cards. Because you clearly cannot throw brute-force algorithm on that. My colleague J. Durisova came with the ingenious idea about dividing the cards into columns and this algorithm is based on that.

The following should work for 3, 4, 6, and 8 symbols on one card.

Notation

K ... number of symbols on one card
FirstCard ... the one and only card that is not in any of the columns
Column_i.Card_j.Symbol_m ... m-th symbol on the j-th card in the i-th column
Comment

Algorithm

  1. Put any K symbols on the FirstCard
  2. Create K columns of K-1 empty cards
  3. For each 1 <= i <= K
    1. For each 1 <= j <= K-1 let Column_i.Card_j.Symbol_1 = FirstCard.Symbol_i
    Now we have K columns and each column has cards sharing one symbol which is also shared with FirstCard.
  4. For each 1 <= i <= K-1
    1. For each 2 <= j <= K let Column_1.Card_i.Symbol_j is any symbol currently unusued on any card.
    Now we complete all the cards in the first column. Because they already share one symbol, all other symbols must be completely different.
  5. For each 2 <= i <= K
    1. For each 1 <= j <= K-1
      1. For each 1 <= m <= K-1 let Column_i.Card_j.Symbol_(m+1) = Column_1.Card_m.Symbol_(((j-1)+(i-2)*(m-1)) % (K-1) + 2)
    Use exactly one symbol from each card in column 1 to make the rest of any other card. But make sure that symbols in one column are different. Basically we transpose cards in a column and symbols on one card. So e.g. Column_2.Card_j.Symbol_m = Column_1.Card_m.Symbol_j. However for different columns we use different step. E.g. for the second column we use step 0, for third column step 1 etc.

Implementation

How many symbols should be on one card: