# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1654: Tricky cards

From New Scientist #2820, 9th July 2011 [link]

Shown right are two of the cards Joe asked Penny to make for him. Joe specified four colours (A, B, C and D) and Penny could choose any one of them for any of the four areas.

Penny had only made a few cards when she turned one round and noticed that it was the same as the one she had just made. She had assumed that all the cards must be different, so she set about calculating how many different cards made up a full set.

How many cards make up the set?

[enigma1654]

### One response to “Enigma 1654: Tricky cards”

1. jimrandell 4 December 2011 at 4:21 pm

This Python program computes the unique colourings of the edges of a square with 4 colours. It runs in 29ms.

```from itertools import product
from enigma import concat, printf

colours = list('0123')

colourings = set()
n = 0
for (A, B, C, D) in product(colours, repeat=4):
s = map(concat, ((A, B, C, D), (D, A, B, C), (C, D, A, B), (B, C, D, A)))
if not colourings.intersection(s):
n += 1
colourings.update(s)

printf("colourings = {nc}, squares = {n}", nc=len(colourings))
```

Solution: There are 70 cards in the set.

This site uses Akismet to reduce spam. Learn how your comment data is processed.