BrainDen.com - Brain Teasers
• 0

# Maximum times with optimize guess method in Guess number gam

## Question

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

Guess#4a: 5672, Result: 0A0B(a), 0A1B(B) or 0A2B© ... MaxRemains: 18

--Guess#5a: 8049, Result: 0A3B(a), 0A4B(B), 1A2B©, 1A3B(d), or 2A2B(e) ... MaxRemains: 3

----Guess#6a: 3890, Result: 1A3B(a) or 2A2B(B) ... MaxRemains: 1

------Guess#7a: 9380 ... 7 times

------Guess#7b: 3980 ... 7 times

--Guess#5b: 4781, Result: 0A2B or 1A2B ... MaxRemains: 3

--Guess#5c: 6748, Result: 1A1B or 1A2B ... MaxRemains: 3

Guess#4b: 3074, Result: 0A1B(d), 0A2B(e) or 1A1B(f) ... MaxRemains: 14

--Guess#5d. 6728, Result: 0A3B, 0A4B, 1A1B, or 2A2B ... MaxRemains: 2

## 2 answers to this question

• 0

I did this, once, back in school.

It was a computer game, and there were colors instead of numbers,

and there could be repeats.

I'll try to work this out later,

but right now my intuition is saying it can be done in ...

8 tries.

##### Share on other sites
• 0

Why is 8?

Maximum times -> worst case.

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

## Create an account

Register a new account