7. Petya thought of a 9-digit number obtained by rearranging the digits of the number 123456789. Vitya is trying to guess it. For this, he chooses any 9-digit number (possibly with repeated digits and zeros) and tells it to Petya, who then responds with how many digits of this number match the ones in his thought number. Can Vitya find out the first digit of Petya's number in no more than 4 moves? (A match is a digit standing in the same place.)
Solution. Vitya's first move is to name the number 122222 222. Then Petya can only respond with 0, 1, or 2.

If Petya answers 0, then neither the one nor the two hit their places. This means the two must be in the first position. There's no need to ask further.

If Petya answers 2, then both the one and the two hit their places. This means the one is in the first position. There's no need to ask further.

If Petya answers 1, then neither the one nor the two can be in the first position. In this case, Vitya will name the next number 344444444. After Petya's response, Vitya will either learn the first digit of Petya's number or understand that it is neither a three nor a four. Next, Vitya will name the numbers 566666666 and 788888888 until he learns the first digit. If Petya also answers 1 to the number 788888888, then the first digit of his number will be the only remaining unchecked digit - 9.