# [Easy challenge] Guessing n Cheating - Bad test case?

#1

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 ?

Guessing n Cheating solution
#2

As said before, you are not Bob.
You must display the first round when you have a proof Alice is cheating

#3

Why would it be 47? The correct answer at that point in the game could very well still be say 52, with nothing inconsistent being said yet.

#4

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

#5

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 ?

#6

Yes, you are right.

#7

Hi everyone! I’m trying to solve puzzle ‘Guessing n Cheating’ and my program passes all cases exept for the last. Here is dump:

50 too low
75 too high
62 too low
69 too low
72 too high
70 too low
17 right on
Alice cheated in round 6

### Failure

Found:
Alice cheated in round 6
Expected:
Alice cheated in round 7

I don’t understand why it is 7, cause the cheating was when she said ‘70 too low’, and even the example shows us such case:

5 too high
1 too high <-- round 2
2 right on

#8

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.

#9

I don’t understand either. I’ve written and rewritten, still get 100% on test cases and 90% on validators. I store the responses and check for disjointed answers, I change the range until a response is invalid, and i even check to see if the top-bottom is <0, and checked for unknown response. The validator that always fails for me is 02. I don’t get it. It’s way too easy for it to fail.

#10

In test case 2,
47 too low
48 too high

Can your code process it to find a cheating in round 2?

If it does, the same principle applies to other numbers, e.g.
11 too low
12 too high

and other directions, e.g.
12 too high
11 too low

You can (and should) produce many more test cases to try it yourself.

#11

I pass all tests but fail 6th and 7th validators. Need a clue. How can I know the conditions inside these validations?

#12

Did you read the posts above yours? Maybe you can find the solution there.

Else, I can give you the validator.

#13

Yes, I did. But it doesn’t help. I think just only one of the validators can help me get the situation.

#15

Hi Thibaud,

I’m also stuck at validators (5,6,7)

If I can get one of those, it would help me.

Thx

#16

#17

Let me reveal more of the secrets in this puzzle.
In my high-school Math there was a chapter “Logic”. This puzzle bases on nothing more complicated than that simple Logic lesson.

Principles

1. All “cheating points” come from a statement contradicting earlier statements.
2. Rules of the game are also kinds of statements (told before the game), so that a statement against the rules of the game is a contradiction.

(from my example given above)
11 too low
12 too high

After the first statement, the valid range becomes [12…100]
Statement 2 implies the valid range is [1…11]. The combination of two statements (use AND to find the overlapping range of two sets) will result in a null range. Null range is not allowed in the game, so that statement 2 makes a contradiction.

Valid range can shrink after new statements. It will never expand.

11 too low
21 too low (New valid statement. Valid range becomes [22…100])

Extreme cases
(from the first sample in puzzle)
1 too high

contradiction to the rule of the game (numbers below 1 are not allowed)

Legal tricks 1 - noise
adding valid statements to the above cases. Add to the front, end, and/or middle.

11 too low
21 too low
12 too high

can become:
11 too low
21 too low
20 too low (noise, does not change the valid range)

Legal tricks 2 - repetition

11 too low
12 too high

can become

11 too low
11 too low
12 too high

or become

11 too low
21 too low (added valid statement)
11 too low (repetition)
12 too high

Remember, noise can be added at the front, end, and/or middle, in multiple places.

Legal tricks 3 - different direction

All the above examples can be completely or partially reversed (reverse the sequence or reverse “high” vs “low”). The contradiction point will be different. Or there can be no contradiction at all.

reversed sequence
12 too high
11 too low
21 too low
11 too low
(After all these explanation, you should know where the contradiction is.)

All these tricks and principles are illustrated in the existing test cases with some possible combinations. Why not giving the full combination of all possibilities? Normally no puzzle can. However, you are now armed with the knowledge to take care of the rest of other unlisted combinations.

#18

Hey, I’m stuck at validators 5, 6 and 7 as well. Regardless of reading this whole thread, I’m not able to find out why they fail…
I’d be grateful if anyone can give me a hint or provide one of these validators.
(It’s my last puzzle from category easy that I have to solve )

#19

@dngo @ChrisDerPlayer you pass all IDE tests and only fail validators 5, 6 and 7?

#20

Yep, only the validators.

#21

Unfortunately also java_coffee_cup’s logic lesson was not helpful. I created custom test cases for all of them and my code seems to work like a charm