Problem

Source: Azerbaijan NMO 2023. Senior P4

Tags: combinatorics, AZE SENIOR NATIONAL MO



To open the magic chest, one needs to say a magic code of length $n$ consisting of digits $0, 1, 2, 3, 4, 5, 6, 7, 8, 9.$ Each time Griphook tells the chest a code it thinks up, the chest's talkative guardian responds by saying the number of digits in that code that match the magic code. (For example, if the magic code is $0423$ and Griphook says $3442,$ the chest's talkative guard will say $1$). Prove that there exists a number $k$ such that for any natural number $n \geq k,$ Griphook can find the magic code by checking at most $4n-2023$ times, regardless of what the magic code of the box is.