# Solution to puzzle 20: Five card trick, part 2

Note: This solution is best read in conjunction with the solution to puzzle 19.

Number the cards in the deck 0 through 123: c0 < c1 < c2 < c3 < c4.  A selects card ci to hand back to the audience member, where i = c0 + c1 + c2 + c3 + c4 (mod 5.)

Now, suppose the four remaining cards sum to s (mod 5.)  Since all five cards sum to i (mod 5), ci , the hidden card, must be congruent to −s + i (mod 5.)  Therefore, if we renumber the cards from 0 to 119 by removing the four retained cards, the hidden card's new number is congruent to −s (mod 5.)

From here, there are exactly 24 possibilities remaining for the hidden card.  These can be conveyed by permutation of the four retained cards.

An example might help to clarify the method.  Suppose the audience member chooses card numbers 10, 34, 61, 78, and 93.

## Encoding by A

We have i = (10 + 34 + 61 + 78 + 93) mod 5 = 1, so A hands card 1 (number 34) to the audience member.

After removing the other four cards and renumbering the cards, the hidden card's new number is 33 = 3 + 6×5, which is the 7th non-negative integer congruent to 3 (mod 5.)

Thus A uses the remaining four cards to encode the number 7, with the permutation: 61, 10, 78, 93.

## Decoding by B

The remaining four cards sum to (10 + 61 + 78 + 93) mod 5 = 2, so the hidden card's new number (after removing the remaining four cards) must be congruent to −2 = 3 (mod 5.)

The permutation 61, 10, 78, 93 encodes 7, so the hidden card's renumbered number is the 7th non-negative integer congruent to 3 (mod 5); i.e., 33.

Precisely one of the four cards is less than 33, so the hidden card's original number was 34.

Source: The best card trick, in Mathematical Intelligencer 24 #1