Baltic Way 2025 · Problem 10
Combinatorics
A positive integer with 9 digits is called nice if it contains each digit from 1 to 9. A number is called wonderful if it is nice and for each , it holds that the -th digit in the number is equal to the position of in the number. For example, 847296315 is wonderful:
- the first digit is 8, which is the position of 1 in the number,
- the second digit is 4, which is the position of 2 in the number,
- the third digit is 7, which is the position of 3 in the number, and so on.
Show that the number of wonderful numbers is even.
When you’re ready
Review material becomes available with the next Daily.
Review
Topics
Pigeonhole and extremal arguments
Solutions
Solution
To any nice number associate another nice number , called its sorting number, uniquely defined by
This is well-defined because every nice number has exactly the digits . A nice number is wonderful exactly when it is its own sorting number.
Let have sorting number . For every ,
By symmetry, is therefore the sorting number of .
Thus all nice numbers that are not wonderful can be paired with their distinct sorting numbers. Hence the number of non-wonderful nice numbers is even. The total number of nice numbers is , also even, so the number of wonderful numbers is even.
Solution 2
Generalize to -wonderful numbers of length , for , and let denote their number. We have and , corresponding to , , and in the two respective lengths.
Consider an -wonderful number with .
- If , then is an -wonderful number.
- If , then . Remove and from and subtract from every remaining digit greater than . This gives an -wonderful number.
Case 1 gives a bijection with -wonderful numbers. In Case 2, the reverse construction is: take an -wonderful number, add to every digit at least , insert in position , and append . This is possible for each .
Therefore
Since , the recurrence shows that is even for every , in particular for .
Contest context
Results from Baltic Way 2025
11 teams
- Mean score
- 4.8 / 5
- Scores of 4 or 5
- 10 / 11
- Estonia
- 5 / 5
Score distribution
All team scores
| Team | Score |
|---|---|
| Germany | 5 / 5 |
| Estonia | 5 / 5 |
| Poland | 5 / 5 |
| Lithuania | 5 / 5 |
| Norway | 5 / 5 |
| Latvia | 5 / 5 |
| Finland | 3 / 5 |
| Denmark | 5 / 5 |
| Sweden | 5 / 5 |
| Ukraine | 5 / 5 |
| Iceland | 5 / 5 |