5. Let be the set of all positive integers that satisfy the following conditions: in their decimal representation, there are ones and twos, and no other digits. Let be the set of all positive integers that satisfy the following conditions: in their decimal representation, they are composed only of the digits 1, 2, 3, and 4, and the number of 1s is equal to the number of 2s, and they are -digit numbers. Prove that .
Problem 1051
Official solution
5. We prove this by establishing a one-to-one correspondence between and .
For every , consider as a permutation of from left to right. Replace all pairs of 11 with 1, 22 with 2, 12 with 3, and 21 with 4. This results in a positive integer consisting of digits. Since the number of 12 and 21 pairs in contains the same number of 1s and 2s, the number of 11 pairs must equal the number of 22 pairs in this process. Thus, we have , which defines a mapping from to .
Now, for every , from left to right, replace 1 with 11, 2 with 22, 3 with 12, and 4 with 21. This results in a positive integer belonging to (since the number of 1s and 2s in the representation of is equal), indicating that is a one-to-one correspondence.