What is the sum of all of the possibilities for Sam's number if Sam thinks of a 5-digit number, Sam's friend Sally tries to guess his number, Sam writes the number of matching digits beside each of Sally's guesses, and a digit is considered "matching" when it is the correct digit in the correct position?
Solution
We label the digits of the unknown number as vwxyz.
Since vwxyz and 71794 have 0 matching digits, then and and and and .
Since vwxyz and 71744 have 1 matching digit, then the preceding information tells us that .
Since and 51545 have 2 matching digits and , then is of one of the following three forms: or or .
Case 1: vwxyz
Since and 21531 have 1 matching digit and , then either or .
If , then and 51545 would have 3 matching digits, which violates the given condition. Thus, .
Thus, and we know that and .
To this point, this form is consistent with the 1st, 2 nd, 3 rd and 7 th rows of the table.
Since and 59135 have 1 matching digit, this is taken care of by the fact that and we note that and .
Since and 58342 have 2 matching digits, this is taken care of by the fact that and , and we note that and .
Since and 37348 have 2 matching digits and , then either or .
But we already know that , and so .
Therefore, vwxyz with the restrictions that .
We note that the integers satisfy the requirements, so are all possibilities for Sam's numbers.
Case 2: vwxyz
Since and 51545 have only 2 matching digits, so and .
Since and 21531 have 1 matching digit, then this is taken care of by the fact that , and we note that and . (We already know that .)
Since and 59135 have 1 matching digit, then or or .
This means that we must have .
Thus, vwxyz and we know that and .
To this point, this form is consistent with the 1 st, 2 nd, 3 rd , 4 th, and 7 th rows of the table.
Since and 58342 have 2 matching digits and , then .
Since and 37348 have 2 matching digits, then .
In this case, the integer 39542 is the only possibility, and it satisfies all of the requirements.
Case 3: vwxyz
Since and 21531 have 1 matching digit and we know that , then or .
But if , then and 51545 would have 3 matching digits, so and .
Thus, vwxyz and we know that and .
To this point, this form is consistent with the 1st, 2 nd, 3rd and 7 th rows of the table.
Since and 59135 have 1 matching digit, this is taken care of by the fact that and we note that and .
Since and 58342 have 2 matching digits, then or , but not both.
Since and 37348 have 2 matching digits, then or , but not both.
If , then we have to have , and so neither nor is true.
Thus, it must be the case that and .
Therefore, vwxyz with the restrictions that .
We note that the integers satisfy the requirements, so are all possibilities for Sam's numbers.
Thus, there are 13 possibilities for Sam's numbers and the sum of these is 526758.