## Pandigital Primes

#### Problem

The digits 0 to 9 are written on ten pieces of card and, by arranging them into five blocks of two, it is possible to form five primes. For example,

0 | 5 | 2 | 3 | 4 | 7 | 6 | 1 | 8 | 9 |

How many different sets of five primes can you form this way?

#### Solution

Clearly zero can only be used as a leading digit: 02, 03, 05, and 07. It is also useful to note that, with the exception of 02, no prime ends in an even digit, so evens must be used as leading digits.

02, 03, 05, 07

23, 29

41, 43, 47

61, 67

83, 89

If we use 02 as one of our numbers, it will be necessary to use a prime made up of two odd digits, as 4, 6, and 8 will be used as leading digits for three out of the other four 2-digit numbers. However, as 5 can no longer be used as a final digit, we know that 5 must be used as a leading digit: 53 or 59.

We shall consider two cases:

__Case 1__ (all leading digits are even)

We can see that 9 can only be used in 29 or 89. But if we use the 9 in 29, we must use the 3 with 83; similarly, if we use 9 with 89, we must the 3 with 23. That is, 3 and 9 must be used with 2* and 8*.

We can now eliminate 03 and 43, and using the same reasoning, we can see that as 1 and 7 must be used with 4* and 6*.

The only possible remaining combination is 05.

This gives the solution sets: {05, 23, 41, 67, 89}, {05, 23, 47, 61, 89}, {05, 29, 41, 67, 83}, and {05, 29, 67, 41, 83}.

__Case 2__ (using 02 and 5*)

By similar reasoning to the first case, we can see that the 3 and 9 can only be used with 5* and 8*.

This leaves 1, 4, 6, and 7, and 41, 47, 61, and 67 are all prime.

Giving the solution sets: {02, 41, 53, 67, 89}, {02, 41, 59, 67, 83}, {02, 47, 53, 61, 89}, and {02, 47, 59, 61, 83}.

Hence there are 8 solutions in total.