1
$\begingroup$

I am trying to solve this code cracking problem. The solution is either the code or all possible solutions if you can't narrow the possibilities.

We have a 5 character code that is consisting of digits {0,1, ..., 7}. We have 10 attempts and for each attempt we have the amount of correctly guessed digits on the right indexes, and the number of correctly guessed digits on an incorrect index.

What I did what to generate all 5 digit numbers consisting of digits {0,1, ..., 7}., however I failed to find any way to narrow the attempts down. Could you help me find the right algorithm? Thanks!

$\endgroup$
2
  • $\begingroup$ Please clarify "the number of correctly guessed digits on an incorrect index". Suppose the code is 11222 and the guess is 22333. What is that number? $\endgroup$ – John L. May 29 '19 at 19:23
  • $\begingroup$ @Apass.Jack The number is 2. $\endgroup$ – james F. May 29 '19 at 20:00
1
$\begingroup$

Your problem is a variant of Mastermind. In particular, it is "Super Mastermind". Wikipedia contains some relevant pointers, and you can find many more by searching for Super Mastermind. For example, Temporel and Kovacs describes a heuristic algorithm that solves Super Mastermind using roughly 5–7 guesses. The same work also contains pointers to other algorithms.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.