Function Repository Resource:

DobbleSets

Source Notebook

Generate a set of integers that can create Dobble cards

Contributed by: Sander Huisman

ResourceFunction["DobbleSets"][n]

generates n2-n+1 sets, each with n numbers, where each pair of sets only has a single number in common.

Details

Dobble is also known as Spot It! in some parts of the world.
n should be an integer.
n-1 should be prime or n should be 2, 5, 9 or 10.
ResourceFunction["DobbleSets"][n] creates n2-n+1 sets, each with n numbers, containing the number 1 through n2-n+1.

Examples

Basic Examples (2) 

Create a small Dobble set:

In[1]:=
s = ResourceFunction["DobbleSets"][3]
Out[1]=

Verify that each pair of sets has a single number as overlap:

In[2]:=
AllTrue[Subsets[s, {2}], Apply[Intersection]/*Length/*EqualTo[1]]
Out[2]=

Scope (2) 

Large sets can be created for primes + 1:

In[3]:=
s = ResourceFunction["DobbleSets"][32];
s // Dimensions
Out[3]=

Verify that each pair has a single number as overlap:

In[4]:=
AllTrue[Subsets[s, {2}], Apply[Intersection]/*Length/*EqualTo[1]]
Out[4]=

Possible Issues (1) 

Not all sizes are possible or are unknown:

In[5]:=
ResourceFunction["DobbleSets"][7]
Out[5]=

Neat Examples (1) 

Generate a set of Dobble-inspired cards where each two cards have only one symbol in common:

In[6]:=
SeedRandom[2];
n = 6;
s = ResourceFunction["DobbleSets"][n];
colors = {Red, Green, Blue, Orange, Magenta};
shapes = Join[RegularPolygon /@ Range[3, 5], Disk[{0, 0}, 1, {0, #}] & /@ Range[Pi/2, 2 Pi, Pi/2]];
shapes = Join @@ Outer[Style, shapes, colors];
shapes = RandomSample[shapes, Length[s]];
pos = Join[{{0, 0}}, CirclePoints[2.5, n - 1]];
cards = MapThread[
     Translate[
       Rotate[#1, RandomReal[{0, 2 Pi}], {0, 0}], #2] &, {shapes[[#]],
       pos}] & /@ s;
Multicolumn[
 Graphics[{#, Circle[{0, 0}, 4]}, ImageSize -> 70] & /@ cards]
Out[6]=

Publisher

SHuisman

Version History

  • 1.0.0 – 03 May 2021

Related Resources

License Information