Call a positive integer fair if no digit is used more than once, it has no 0s, and no digit is adjacent to two greater digits. For example, , , and are fair, but , , and are not fair. How many fair positive integers are there?
- A)
- B)
- C)
- D)
- E)
Answer
C
Key insight
No interior digit may be a local minimum, so the digits rise to a peak then fall, and any chosen set of k digits admits exactly 2^(k-1) orderings.
Solution
The first two conditions say the digits form a sequence of distinct elements of , so a fair number uses a subset of size for some , and no leading-zero worry arises. The third condition says no interior digit has both of its neighbours larger — that is, no interior digit is a local minimum. (End digits have only one neighbour, so they are never at fault.)
Step 1: the shape of a fair number. A string of distinct digits has no interior local minimum exactly when it increases up to its largest digit and then decreases.
One direction is immediate: in a string , every digit before the peak has a smaller digit on its left, every digit after the peak has a smaller digit on its right, and the peak is larger than both neighbours, so nothing is a local minimum.
Conversely, suppose the string is not of that shape. Then somewhere it goes down and later comes back up: there is a descent followed by an ascent with . Take the first ascent after that descent; then , so while , and position is an interior local minimum. So the number is not fair.
Step 2: count the orderings of a fixed digit set. Fix a set of digits. Its largest element must sit at the peak. Each of the other digits is assigned to the increasing run (left of the peak) or the decreasing run (right of the peak); once the sides are chosen, the order within each run is forced, since the left run must be increasing and the right run decreasing. Different side-assignments give different strings, so there are exactly
fair numbers using that digit set. Sanity check with and digits : the four strings are , , , , while and both have the trapped between two larger digits.
Step 3: sum over all digit sets.
(Quick checks: gives one-digit numbers, and gives , which is every two-digit number with distinct nonzero digits, as it should be — no two-digit number can fail the adjacency rule.)
The answer is .
Why this works
A local condition on neighbours ("nothing sits in a valley") is almost always secretly a global shape condition, and identifying that shape is what turns an intractable adjacency constraint into a clean choice for each element. Once the shape is "up then down", counting splits in the standard way: choose which digits appear, then count the arrangements of that fixed set, and the second count depends only on . The factor rather than is the whole difficulty of the problem — the maximum has no choice of side — and it is exactly what separates the correct from the decoy .
Alternative approach
Count in one stroke by labelling. Give each of the digits through one of three labels: unused, left (on the ascending run), or right (on the descending run). That is labellings. Every labelling except the all-unused one determines a string — read the left-labelled digits in increasing order, then the right-labelled ones in decreasing order — and each fair number arises exactly twice, because its largest digit can be labelled left or right without changing the string. Hence
which again gives .
The trap
Summing binom(9,k) * 2^k instead of binom(9,k) * 2^(k-1), which gives 3^9 - 1 = 19682, choice (E); the factor 2^(k-1) is right because the largest digit's position is forced.
Common mistakes
- Summing binom(9,k) 2^k instead of binom(9,k) 2^(k-1), which gives 3^9 - 1 = 19682, choice (E); the factor 2^(k-1) is right because the largest digit's position is forced.
- Treating the first or last digit as capable of being "adjacent to two greater digits"; an end digit has only one neighbour, so and are fair even though their smallest digit is at an end.
- Forgetting that the number of digits ranges over all of through , and counting only nine-digit numbers () or only the subsets (, choice (A)).
Techniques
Apply an identity: SFFT, sum of squares, difference of cubes, Vieta · Map the objects to something easier to count