How many 4-digit numbers are there with the property that
Note that the first digit of a four-digit number cannot be zero.
Solutions — 3
Solution 1
16.
Let then can take the values . For we find 9 numbers . For other values of , we take each of the eight sequences
and find possible starting points to produce numbers with that particular sequence indicating for each digit whether the next digit is smaller or larger.
Case 1. `+++` (9 solutions)
gives
gives
do not give further solutions.
Case 2. `++−` (16 solutions)
gives
gives
gives
gives
Case 3. `+-+` (36 solutions)
| Numbers | |
|---|---|
Case 4. `+--` (20 solutions)
| Numbers | |
|---|---|
Case 5. `-++` (20 solutions)
| Numbers | |
|---|---|
Case 6. `-+-` (45 solutions)
| Numbers | |
|---|---|
Case 7. (20 solutions)
gives
gives
gives
gives
do not give further solutions.
Case 8. (12 solutions)
gives
gives
gives
Adding the 9 with to the count for each pattern, we obtain
.
Solution 2
Let so can take integer values from to inclusive. If then there are cases. So let us consider . We will first count the cases including those where is permitted and then subtract those cases starting with zero.
When , there are four possible patterns for the three differences, namely
* Case . This requires two distinct digits separated by a gap , with cases.
* Cases and . This requires three distinct digits in arithmetic progression, with cases if and none otherwise.
* Case . This requires four digits in arithmetic progression with gap of , i.e. the smallest digit must satisfy , which gives cases if and no cases otherwise.
Now let us enumerate the cases with initial digit and . There are no examples with . If , the difference pattern is impossible as it results in a negative final digit. The pattern has solutions for any , the pattern has solutions for any , the pattern has no solutions as the final digit cannot be negative, while the case has a solution if .
We can now summarise all the cases according to the value of in the following table.
| $ | d | $ | |||
|---|---|---|---|---|---|
| 0 | 9 | ||||
| 1 | 32 | 32 | -3 | ||
| 2 | 24 | 24 | -3 | ||
| 3 | 16 | 16 | -3 | ||
| 4 | 10 | 10 | -2 | ||
| 5 | 5 | 5 | -1 | ||
| 6 | 4 | 4 | -1 | ||
| 7 | 3 | 3 | -1 | ||
| 8 | 2 | 2 | -1 | ||
| 9 | 1 | 1 | -1 | ||
| Total | 187 |
The solution to the problem then is 187 cases.
Solution 3
Let .
For each value of from 0 to 9, set up a tableau with 4 rows (numbered 1 to 4) and 10 columns (numbered 0 to 9). The number in row and column is the number of -digit numbers, ending in the digit , that have an absolute difference of between adjacent digits.
In row 1, for all we have because there is no 1-digit number ending in zero, while for . In subsequent rows, by considering appending a final digit to a number of digits, is the sum of and when . These summands are taken to be zero if the reference overspills the tableau, i.e. if or . In the special case , the rows are all equal to the first row. The tableaux are shown below.
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Total | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |||
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |||
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |||
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 9 |
The total of the totals is 187.