Guess number game: pick 4 digits from 0-9. one digit cannot pick twice.
Then, create a method to guess that number. If the position is right, marks "A". otherwise, marks "B". Then, count As and Bs.
For example, the answer is "1234", but guess "1024". Then the result is "2A1B".
With best guessing method (you need to find), and in worst situation, choose the maximum times the method needs to guess any 4 digits-non-repeat numbers.
a.4,
b.5
c.6
d.7
e.8
f.9
g.10
h.11
i.12
j.none of above.
The answer is d. 7 times.
Guess#1: 1234, Result: 0A1B ... MaxRemains: 1440
Guess#2: 0156, Result: 0A1B ... MaxRemains: 378
Guess#3: 2507, Result: 0A1B(a) or 0A2B(B) ... MaxRemains: 88
Question
Guest
Guess number game: pick 4 digits from 0-9. one digit cannot pick twice.
Then, create a method to guess that number. If the position is right, marks "A". otherwise, marks "B". Then, count As and Bs.
For example, the answer is "1234", but guess "1024". Then the result is "2A1B".
With best guessing method (you need to find), and in worst situation, choose the maximum times the method needs to guess any 4 digits-non-repeat numbers.
a.4,
b.5
c.6
d.7
e.8
f.9
g.10
h.11
i.12
j.none of above.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.