# Placing three sets of cards Ace to 9 in a row

From an ordinary deck of playing cards remove cards ace to nine of any three suits (27 cards in all), and place them in a row so that between any 2 consecutive aces there is precisely 1 card, between any 2 consecutive twos there are 2 cards, and so on, up to 9 cards between any two consecutive nines.

Below, for your convenience, five cards have already been placed for you:

_ _ _ _ _ _ 4 _ 3 _ _ _ _ _ _ 5 _ 2 _ _ _ _ A _ _ _ _

Solution:

3 4 7 9 3 6 4 8 3 5 7 4 6 9 2 5 8 2 7 6 2 5 A 9 A 8 A

Finding the Solution:

If card n cannot be placed to another card n's right, it must be placed to its left and vice versa. This rule can be applied for cards that are separated by another card n as well. Starting with _ _ _ _ _ _ 4 _ 3 _ _ _ _ _ _ 5 _ 2 _ _ _ _ A _ _ _ _, we can tell that we can't place both 4's to the initial 4's left, so one must go on the right. Similar logic can be used for the initial 5.

This gets us:

_ _ _ _ _ _ 4 _ 3 5 _ 4 _ _ _ 5 _ 2 _ _ _ _ A _ _ _ _. Now, we know that we can't place both 2's to the left, so one must be placed to its right. This blocks the Ace to the left, so all Aces must be placed on the right.

We now have:

_ _ _ _ _ _ 4 _ 3 5 _ 4 _ _ _ 5 _ 2 _ _ 2 _ A _ A _ A. We have run out of places to use this rule for now, so let's see if we can narrow down a bigger number's location. The first 9 can only be placed in 7 locations (or else it will run out of space), and 4 of them are blocked on the right side, so we only have to test 3. It only fits in 1 space, so we can put the rest of the 9's down.

This gives us:

_ _ _ 9 _ _ 4 _ 3 5 _ 4 _ 9 _ 5 _ 2 _ _ 2 _ A 9 A _ A. Now, our 5 is blocked to the left and our 2 is blocked to the right.

Now, we have:

_ _ _ 9 _ _ 4 _ 3 5 _ 4 _ 9 2 5 _ 2 _ _ 2 5 A 9 A _ A. After this, we need to put a larger number down again, and 6 happens to fit in only 1 way. Once we do that, we can finish out the 3's.

Here we have:

3 _ _ 9 3 6 4 _ 3 5 _ 4 6 9 2 5 _ 2 _ 6 2 5 A 9 A _ A. Now, there is a space to the right where we can either put 7 or 8. 8 is the only number that fits. After that, there is only one place that 7 fits. We put the final 4 in and the puzzle is complete.

In conclusion:

3 4 7 9 3 6 4 8 3 5 7 4 6 9 2 5 8 2 7 6 2 5 A 9 A 8 A.