You probably have thought that Bob is doing the best possible thing and all his guesses are good guesses but this is not the case. Look at some of the test data and see how he guesses.
There are two sorts of approaches that I thought of,
Keep track of all possible numbers
Keep track of the range
I naively thought the second approach is just much simpler and efficient and went with that, but notice that because of the way Bob plays, you have to pay more attentions when changing the states.
I hope this helps others who had problems passing the validators.
(I also agree with the others that tests could have checked for some extra edge cases that the validators check, but it’s at least a good learning experience that in real problems you don’t have a comprehensive set of tests to help you spot your mistakes and even worse in reality you find out you were wrong when it’s too late!)
I had trouble with this puzzle like many others. I tried to solve it by keeping a range (min, max) of valid numbers. One crucial tip I would like to give to others is: Bob is not a smart player and will not always “zoom in” on the correct number.
For those that pass all test cases but fail 2 or 3 of the validations, try the following custom test case:
4
75 too high
25 too low
10 too low
20 right on
With the expected result:
Alice cheated in round 4
This was a fun puzzle, but like others have said, validation cases should not introduce new edge cases and the case I quoted above (or a similar one) should really be added to the test cases.
Hi, I’m trying to solve the Guessing n Cheating challenge in Python3 and I can’t seem to pass the no cheating test cases, the expected answer keeps changing. Example: In case 3
print(“No evidence of cheating.”)
Found: No evidence of cheating.
Expected: Nothing
print("")
Found:Nothing
Expected:No evidence of cheating
Hi, i don’t understand the test case on Guessing n Cheating challenge. When i look em up, i see an error on 4 of them, here are some example
History : 47 too low,48 too high,49 too high,50 too high,47 right on
Trouvé : Alice cheated in round 1
Attendu : Alice cheated in round 2
But if 47 is the answer, the cheat is on round 1 cause “47 too low” is a lie, “48 too high” is ok
Other example :
50 too low,52 too high,51 too low,52 too low,50 too high,53 right on
Trouvé : Alice cheated in round 2
Attendu : Alice cheated in round 3
if 53 is the right answer, the cheat is in round 2, “52 too high” is a lie
When i look manually my code is okay but the validation don’t pass for 4 test case and half the real validators. Is there an error in this challenge or is there something i missunderstood ?
The only case you can say Alice is cheating right on the first round is when she gives a number out of bound.
In every other case you need more pieces of evidence to accuse Alice
Oh okay i think a understand, the example mislead me, i thought we were suppose to find the first lie, but we are suppose to find when he should have guessed she lied. So in the example :
3
5 too high
1 too high
2 right on
The lie is “1 too high” because it can’t be zero, not because 2 is the answer, right ?
When she says 70 too low it is still possible that 71 is the answer. You can’t prove there was cheating until the next round when she says it isn’t 71.
In the example saying 1 is too high is cheating as no numbers are less than 1.