Everything is contained in the image. For any clarification, comment down below.
2 Answers
I don't understand why the creator of the answer before deleted their post - It was correct as far as I can tell:
04873
8 > (all other digits in the solution)
4-3 = 1
{ 6, 9, 1, 7, 2 } only contains 7 in the correct position, all other digits are not existent within the solution
{ 4, 5, 2, 8, 6 } only contains 4 and 8 in the wrong positions, all other digits are not existent within the solution
{ 3, 8, 5, 1, 2 } only contains 3 and 8 in the wrong positions, all other digits are not existent within the solution
Assuming my interpretation of the constraints are correct, this is the only possible solution
-
$\begingroup$ (FYI) The previous answer was deleted on review as no explanation was provided more than two hours after stating that an edit would follow. For a puzzle of this level that seems a long time to leave a towel on the poolside deckchair... $\endgroup$– StivSep 7, 2020 at 8:53
Detailed reasoning associated to Shahriar Mahmud Sajid's answer
69172 - One digit is correct and in the right place
It cannot be the middle 1 as there is no possibility for it to be the greatest and it cannot be the 9 as the middle will then not be greater. Hence, it must be the 6, 7 or 2 (and if the 2 is correct, then the second digit is 3).
38512 - Two digits are correct but in the wrong place
This invalidates the 2 being the last digit from before which means either the first digit is 6 or the fourth digit is 7. We now know from before that the code does not contain 9, 1 or 2 which means it must contain two of 3,8 or 5, none of which are in the places shown above.
45286 - Two digits are correct but in the wrong place.
We know one of either 8 or 5 is in the code.
Suppose the first digit of the code is 6. Then exactly one of the 5 or 8 is included and 4 and 2 do not appear in the code.
We know that 9 is not involved so if 8 appears it must be the middle digit. However, we then do not have two consecutive digits to fill in the gaps two and five.
If 5 appears it must be in the 4th position but again we do not have a pair of consecutive digits to fill in the second and last spaces.
Therefore, the 4th digit must be 7 and we do not have 1,6,9 or 2 in the code.
Because the middle digit is the largest, it must be 8.
The remaining digits are 0,3,4,5 which must appear in the other four places. This means that the second and fifth digits are (4,3) or (5,4), respectively and since only one of (3,5) can appear, the first digit must be 0.
Finally, if both 4 and 5 appear then the code 45286 has three digits in the wrong places, contradicting the last statement. Thus the code must be 04873 as found by Shahriar Mahmud Sajid