Welcome to BrainDen.com - Brain Teasers Forum. Like most online communities you must register to post in our community, but don't worry this is a simple free process. To be a part of BrainDen Forums you may create a new account or sign in if you already have an account.
As a member you could start new topics, reply to others, subscribe to topics/forums to get automatic updates, get your own profile and make new friends.
If you like our site, you may support us by simply clicking Google "+1" or Facebook "Like" buttons at the top.
If you have a website, we would appreciate a little link to BrainDen.
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.
Worst case : So, if the answer is cheated, it should do:
Choose the result that ends up with largest availablilities.
For example, it always replies first guess with "1B" (5040 -> 1440).
So, the second guess as a optimize guess method should pick the inside range one to gest smallest narrow down-ed range. So, the output looks like, for example:
1234 -> 1B
4096 -> 1B