[Community Puzzle] Guessing n Cheating

I’m baffled by this puzzle too.
I simply keep track of the high and low value limits according to Alice and detect inconsistencies based on that range of possible values. That is enough to pass all the tests, and yet half of the validators fail.
This is pretty frustrating.

Is there some subtle trick à la Ulam’s liar game there? Is Alice allowed to lie as often as she wants, or just once?

I don’t know, you must have to print the rank of the first answer that is inconsistent.

I started to create a Giant Factory to solve this one…
Until I realized I could get the 100% by cheating!

The answer wording is pretty confusing.

Take the last test for instance. Alice lied all the way. The answer should be “Alice cheated in round 1 (and 2, 3, 4, 5 and 6 if you really want to know)”.
Round 7 is actually the only round where she didn’t cheat :slight_smile:

What the puzzle want us to find is the first round where it is possible to prove Alice cheated, with no knowledge of the following answers.

The examples prove Alice is allowed to lie as often as she pleases. She could give “too high” and “too low” answers at random for all she cares, as long as Bob doesn’t guess the right number.

All we can do is narrow down the range of possible values assuming Alice always says the truth and stop when Alice’s answer places the number to guess outside that range.

My first attempt was keeping track of a simple [low,high] range. It was enough to pass all the available tests, but for the life of me I didn’t understand how the validation tests managed to make that fail.
I’ve finally solved the puzzle with an inglorious brute force approach (keeping track of every single value), but I had to look at the other solutions to understand why my previous attempt didn’t work.

I’d say there is some critical case that only the validation tests cover. This is pretty unfortunate, as it can leave you stranded with a “nearly working” solution for ages.

Hi,

Have you reached 100% at submission ? My code verifies all the tests but fails at 80% after submission. Have I missed some special case besides 1 and 100 ?

Thanks in advance

Heard that people are getting difficult time at solving this puzzle. Here is some generalized suggestions that might help you look at the problem from a different view point.

Tips #1: You are no Bob.
Do not fall into the trap of pretending yourself be Bob. You are not playing the guessing game. Your target is not to find out the “correct” number hidden by Alice. No need to know the number. There is no number. There is no spoon.

Tips #2: Your target is to prove Alice is making a false statement.
We have the presumption of innocence. One is considered innocent unless proven guilty.
Whatever Alice said, as long as it is (1) in line with the rule of the game, and (2) does not contradict with what she previous said, then we assume her new statement is a true statement. Otherwise, the statement is false and you can catch Alice red-handed.

Tips #3: Know the rule of the game.
Read the statement carefully. Every sentence and every word has a purpose (otherwise I should not have allowed it to appear).
I know you are feeling how dumb Bob was in the game. But being dumb is innocent. He is adding confusion to you but the game allows it.
Focus on logic. It is a logic game.

(If you want to play as Bob to be a smart hero, try hands on the Batman puzzles “Shadows of the Knight”)

1 Like

I have 100% tests, but only 80% with submit (6 and 7 fails)

What’s wrong?

2 Likes

I see two problems with this puzzle:

  1. the wording of the answer.
    “Alice cheated on turn X” is plain wrong. The turn we need to ouput is the one where we could deduce Alice cheated. “I knew Alice cheated on turn X” or something like that.

  2. This is yet another puzzle where a wrong yet convincing solution will fail validaton while passing all tests.
    I don’t like puzzles that lull players into a false sense of accomplishment only to punish them with red validators.
    Validators are supposed to avoid hard coded solutions, In my opinion, a legit progam should pass validation with flying colors. That means tests should detect the same pitfalls as validators do. This is clearly not the case here.

6 Likes

“Alice cheated…”
vs
“I knew Alice cheated…”

Really matter?
And the problem was explained not by a single output line. Statement + input + output + sample cases are supposed to be enough not to mislead.

About validators, it is unfortunate that no one can guarantee ALL possible source codes passing the test cases must be able to pass the validators. In real-world programming projects, test cases during development help to reduce bugs, but it cannot eliminate unexpected cases to appear in production to crash the codes. What the industry can do is to throw in hundreds or thousands of test cases and automate the testing procedure, to reduce bugs as far as possible. But bugs can still be here and there after all testing.

In this platform we’ve only a very limited number of test cases. However we’ve done our best to make the validators look similar to, but yet still different from, the test cases.

1 Like

Well it certainly mislead a few people. It’s not such a big deal though, the examples were indeed quite clear.

I suppose validators here could simply be carbon copies of the tests, with non-significant answers added (Bob making the same guess a few times with the same answers from Alice).
That would guarantee the turn number could not be hard coded while exercising the code the exact same way (assuming it won’t deduce anything from two identical guess/answer pairs).

What bugged me in this challenge is to see my mistake in another’s solution.
There is clearly a condition you must check while maintaining your [low,high] range that i missed in my analysis of the problem. I realized it as soon as I saw it in several variants of the solution.
I was surprised this condition was not checked in any of the tests while the validator caught it.

You can look at my solution if you like, i left a commented copy of the solution that would pass the tests and fail the validation.

Luckily for me, in that case I had a backup plan that worked so I could pass the validation and understand what i had done wrong in the first place.
In the general case there is no such plan B and you’re stuck in front of uncooperative validators.

Maybe it’s just bad luck, I don’t hold a grudge against anybody, but that’s the reason why I voiced a critical opinion on this particular puzzle.

3 Likes

Any guess what you supposed to do after getting 100% on tests and failing on validators?

Any guess what you supposed to do after getting 100% on tests and failing on validators?

This is a situation I frequently encounter, not only on this site.
I’ll do several things:

  1. review the requirements, read all information again carefully.
  2. review my assumptions, get super suspicious to any info not said by the requirement but that I just ‘know’ it.
  3. review my source code. Add lots of debugging messages to it. Run critical blocks step-by-step trying to detect logical errors.
  4. if the problem is related to knowledge from external sources, find reference of these extra knowledge. I enjoy this part. It is high time to learn new things - new algorithms, new programming skill, new languages, new spectrum of knowledge.
  5. based on refreshed knowledge and info, run my imagination engine: day-dreaming, night-dreaming, brain-storming. Think out-of-the-box. Think out-of-myself, out of the way I usually will follow.
  6. do experiments - use the “what if” approach. What happens if I change this bit in the source? What happens if I change that bit in the input?
  7. construct my own inputs. For simple ones I can hand-craft a few and put the dreaming result into the inputs. For complex inputs I might write a program to generate them, either from some known patterns or by random.
  8. consult others - reviewing forum messages and discussing with other people
  9. if all in vain, put it down, forget it for some days. Pick it up again and rerun the above route.

+1 to this, this puzzle is badly designed, IDE TC should be updated to prevent this kind of issue.

Why don’t you just simply update your TC to prevent the issue several people encountered? The issue is pointed out, just fix it for the sake of future users trying to solve this.

2 Likes

Hello, all tests pass when I submit my code, except the test “Elimination”. I tried different validator but my code passes good, but not in validation. What is the wait for this test?

I also passed all the test but failed the validators (at first I failed 3, but then I failed only the last two).

I’d like to provide some more hints as well:

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,

  1. Keep track of all possible numbers
  2. 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!)

2 Likes

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.

3 Likes

Brilliant approach. Not only you helped me pass the validators, but you taught me how to help other people. Thanks!

Try the following custom test case as well.

4
50 too low
60 too high
40 too high
39 right on
Alice cheated in round 3

Hope this helps someone !!!

1 Like

I tried both custom test cases (SylverFox’s and the one from lifetimeLearner007) but my code is still printing the correct answer.

So I still don’t know why its passing all test cases but Validator 6 and 7 not :confused: