# The Dobble Algorithm

Dobble (Spot It! in the US) is a speedy observation card game for 2 players or more. During the game, players have to spot the identical symbol between two cards as quickly as possible to collect cards and score points.

#### The Dobble rule!

Each card of the deck contains 8 graphical symbols. The deck contains 55 cards in total and there is always one and only one symbol in common between any two cards of the deck.

In order to create a deck of cards to follow this rule we need to apply some mathematical logic.
The mathematics behind the game of Dobble is fully explained on this blog post: http://www.petercollingridge.co.uk/blog/mathematics-toys-and-games/dobble/.

We will base our algorithm based on the following key findings:
If a game of Dobble needs (n+1) symbols on each card, n being a primary number then we will need:

• A collection of n2 + n + 1 symbols
• We will be able to generate n2 + n + 1 unique cards

#### The Dobble Matrix

To complete this challenge, it may be easier to consider the following Matrix used for a game of Dobble with only 4 symbols per card (n=3).
We will use 32 + 3 + 1 = 13 symbols to generate 13 cards with 4 symbols per card.

This matrix enables us to visualise which symbols will appear on each card and it also enables us to check that any two cards of the deck have one and only one symbol in common.

The real game of Dobble has 55 cards with eight symbols on each card. Note that with 8 symbols per card, it would have been possible to create 57 cards following the Dobble rules (72 + 7 + 1 = 57) . For some reason, 2 cards were dismissed and the actual game only contains 55 cards.

#### The Dobble Algorithm

For this challenge we have decided to write an algorithm to generate the 57 possible cards for a game for Dobble. The algorithm will be based on the symbols used in the real game. The challenge consists of identifying the 8 symbols to be be used on each of the cards, making sure that the Dobble rule is always respected:

There must always be one and only one symbol in common between any two cards of the deck.

#### Python Code/Solution

Did you like this challenge?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 26

No votes so far! Be the first to rate this post.

As you found this challenge interesting...