Rust: Mastermind: A guessing game for clever people (task 2: The code breaker)
Mastermind in a a classic guessing game and works like this: You have to guess a 6 digits number in the minimum amount of tries possible. For each try, the reply will be how many digits you got right and in the correct position and how many you got right but in the wrong position.
Your job is to implement a small program that will try to guess a number. It will try with a random number, then wait for the user to type a reply. That will will always be exactly 2 digits, the first one being the number of digits in the correct position and the second the number of digits that match but are not in the right position.
For example is the number we have to guess is 123456
and the program tries
The reply would be 21 (because 2 digits, 1 and 2 are in the right place, and 5 is in the wrong place).
If the guess matches the number, the reply would be 60 (all digits in the right place). In this case the program would exit with a message "I guessed it!"
To get started take a look at this other guessing game, which is not the same one but has the same mechanics for a lot of things:
You can check the mastermind rules here: