Oct-12-2017, 01:30 PM
Im taking a basic python course in university and my class project is creating something like mastermind.
We have to create a program that guesses the 4-digit number you're thinking (digits from 1 to 6) in 9 tries or less. The only questions I can ask are: 'how many numbers are correct in the correct position?' and 'how many numbers are correct in the incorrect position?'.
Right now I have a program that loops 9 times through the 2 questions after guessing a number and stores the number and answers in a list. My problem is that my guesses are simply random numbers that do not take into account previous answers. I'd appreciate any tips on how to improve the guessed number every time. I can do it manually but I just can't figure out how to put it in Python.
We have to create a program that guesses the 4-digit number you're thinking (digits from 1 to 6) in 9 tries or less. The only questions I can ask are: 'how many numbers are correct in the correct position?' and 'how many numbers are correct in the incorrect position?'.
Right now I have a program that loops 9 times through the 2 questions after guessing a number and stores the number and answers in a list. My problem is that my guesses are simply random numbers that do not take into account previous answers. I'd appreciate any tips on how to improve the guessed number every time. I can do it manually but I just can't figure out how to put it in Python.