Chapter 75
Can You Crack The Case Of The Crescent Moon?
Riddler Express
Each card is an equilateral triangle with a digit (–) on each of its three sides, no digit repeated on a card. Two cards are the same if one can be rotated onto the other. How many distinct cards can a deck hold? Extra credit: if a digit may appear two or three times on a card?
Solution
A card is a choice of digits for the three sides, read up to rotation of the triangle. With three distinct digits, first choose the set of three from ten in ways. Each set can be placed on the three sides in orders, but a triangle has three rotations, so those six orders collapse into genuinely different cards (the two cyclic orders, clockwise and counter-clockwise). Hence Allowing repeats adds two more kinds of card. A card with one digit on all three sides: of them. A card with one digit twice and another once: choose the two digits in ways and pick which is doubled ( choices), and rotation makes the single arrangement unique, giving . Adding these,
The computation
Enumerate all digit triples, reduce each to its smallest rotation as a canonical form, and count the distinct ones (with and without allowing repeats).
from itertools import product
def count(allow_repeats):
seen = set()
for t in product(range(10), repeat=3):
if not allow_repeats and len(set(t)) < 3: continue
seen.add(min(t, t[1:] + t[:1], t[2:] + t[:2])) # canonical rotation
return len(seen)
print(count(False), count(True)) # 240, 340