Suppose that cards numbered are arranged in a row. The task is to pick them up in numerically increasing order, working repeatedly from left to right. In the example below, cards are picked up on the first pass, and on the second pass, on the third pass, on the fourth pass, and on the fifth pass. For how many of the possible orderings of the cards will the cards be picked up in exactly two passes?

- A)
- B)
- C)
- D)
- E)
Answer
D
Key insight
Two passes means cards 1 to k appear in increasing order and so do cards k+1 to 13. Choosing which k spots hold the first group decides the whole row.
Solution
Step 1: a small case. With cards, check all rows:
| Row | Passes |
|---|---|
| (first , then ) | |
| (first , then ) | |
| (first , then ) | |
| (first , then ) | |
So rows take exactly two passes. Notice that in each of them the first pass takes and the second pass takes the rest.
Step 2: what two passes means. A pass picks up cards in increasing order while moving to the right. So if the first pass collects , those cards appear from left to right in increasing order. If the second pass collects all the rest, then also appear from left to right in increasing order. Here is between and .
Step 3: count rows made of two increasing groups. Fix . To build such a row, choose which of the spots hold the small cards. Then the small cards fill those spots in increasing order, and the big cards fill the other spots in increasing order. So there are such rows.
Step 4: remove the one row that takes a single pass. One of those rows is itself. Every other one takes exactly two passes. The first pass collects to ; could it keep going to ? Only if is to the right of . But is the rightmost small card and is the leftmost big card, so that would put every big card after every small card, which is the sorted row. So in every other row the first pass stops at , and the second pass sweeps up to in order. That gives rows for this .
Step 5: add over . Different give different rows, since is how many cards the first pass collects. So the total is
All the from to add to (the number of ways to pick any group of the spots). Leaving out and gives . Then subtract the sorted rows: .
Check with cards: , matching the table.
The answer is .
Why this works
"Picked up in one pass" means "appears in increasing order", so a two-pass row is two increasing groups mixed together, and mixings are counted by choosing spots. The details to watch are the one sorted row for each , which needs only one pass, and the fact that each row has only one possible , so nothing is counted twice.
The trap
Forgetting to remove the fully sorted row 1, 2, ..., 13 for each k (it takes only one pass), which gives 8190 instead of 8178.
Concise solution
Suppose the first pass collects exactly the cards and the second pass collects , where . A pass picks up cards in increasing order while scanning left to right, so in the row the cards appear in increasing order, and so do the cards .
Conversely, take any row in which both blocks and appear in increasing order. The first pass certainly collects . It continues to only if sits to the right of . But is the rightmost card of the first block and the leftmost of the second, so that would put the entire second block to the right of the entire first block, making the row , which is collected in one pass. Every other such row takes exactly two passes, with the first pass ending at .
For a fixed , a row with both blocks increasing is determined by choosing which of the positions hold the first block: rows, of which one (the sorted row) must be excluded. Different give different rows, since is the number of cards collected in the first pass. Therefore the count is
The answer is .
Review in the AoPS books
- Introduction to Counting & Probability, Chapter 1: Counting Is Arithmetic
- Introduction to Counting & Probability, Chapter 2: Basic Counting Techniques (§2.5)
- Intermediate Counting & Probability, Chapter 13: Events With States (§13.4)
- Intermediate Counting & Probability, Chapter 4: Constructive Counting and 1-1 Correspondences (§4.4, §4.5, §4.6)
Techniques
Map the objects to something easier to count · Split into exhaustive cases and handle each