This is a solution to the “Four Wizards” puzzle. Credit for the puzzle goes to Tanya Khovanova, who found it on Facebook.

The puzzle itself is inlined for convenience:

Wizards Puzzle Statement #

Four wizards A, B, C, and D, were given three cards each. They were told that the cards had numbers from 1 to 12 written without repeats. The wizards only knew their own three numbers and had the following exchange.

A: “I have number 8 on one of my cards.”

B: “All my numbers are prime.”

C: “All my numbers are composite. Moreover, they all have a common prime factor.”

D: “Then I know the cards of each of you.”

Given that every wizard told the truth, what cards does A have?

Reasoning #

This problem is a great example of deductive reasoning. First, let’s define some terms.

A “composite” number is one that comprises of multiple smaller numbers, excluding 1. Therefore, any non-prime, non-1 number is a composite.

Note that C’s cards have to share a common prime factor. Since the numbers only go up to 12, the prime factor options are 2 and 3. A hand that shares a prime factor of 5 would be {5,10,15}, and 15 isn’t a valid card.

With that, we can outline the possible candidates for the cards in each players hands:

  • A: definitely 8, possibly 1,2,3,4,5,6,7,9,10,11,12
  • B: possibly 2,3,5,7,11
  • C: 3 out of the set of {6,9,12} (composites of 3) or {4,6,10,12} (composites of 2)
  • D: possibly: 1,2,3,4,5,6,7,9,10,11,12

In order for player D to be able to deduct that hands of A, B, and C, they have to have cards in their hand that allow them to rule out all but one possibility for the other’s hands. This means that player D must have cards in their hand that overlap with possible cards of A, B, and C.

Let’s start with what cards could remove options for player C. Enumerating cards that C and D could both have:

  • D has 6: rules out composites of 3, C must have {4,10,12}
  • D has 9 or 12: rules out composites of 3, C must have 3 of {4, 6, 10,12}
  • D has 2 of 4, 6, 10, or 12: rules out composites of 2, leaves composites of 3.

Out of these options, the option that uses the least cards in D’s hands to uniquely identify C’s hand is one card with the value 6: this means C must have {4, 10, 12}.

If we make that assumption, then that leaves 2 cards in D’s hand to uniquely identify B and A’s hand.

Note that for B, there are 5 possible prime numbers. If we take any 2 and put them in D’s hand, then we know what cards are in B’s hand. Note that we don’t need to what the precise primes are in B and D’s hands: we just need to know that, if D had two prime cards in their hand, then they would be able to deduce the three primes in B’s.

So with the D’s hand of 6 and 2 prime numbers, we know exactly what is in B and C’s hands. That leaves A.

Among the set of possibilities that A has:

{8} + 2 x {1,2,3,4,5,6,7,9,10,11,12}

We can remove 6 and {4,10,12} that we derived from player C:

{8} + 2x {1,2,3,6,7,9,11}

And remove all the prime numbers since they will be in either B or D’s hand:

{8} + 2x {1,9} = {1,8,9}

And figure out that A has the cards 1,8 and 9.

Solution #

In summary, the solution is 1,8 and 9. Note that since the question doesn’t ask what cards are in the hands of the other players, there are multiple permutations of cards that could satisfy the problem: namely, the primes can be distributed freely as long as 3 are in B’s hand and 2 are in D’s.