Bender - Episode 1 - Puzzle discussion

From the PHP documentation of stream_get_line:

Each line has length of $C characters + the EOL. When you call stream_get_line(STDIN, $C, "\n") for the first time, it will indeed read $C characters but it won’t consume the EOL so the next call will immediately see this EOL and return an empty string.

When you want to be sure to read the whole line, you can use fgets(STDIN) then trim the EOL.

This one was probably the most fun so far =)

2 Likes

Salut salut !
Je suis un peu perdu sur les tests de validation du bender dépressif, de mon coté je ne passe pas "simples mouvements, ni mode casseur, ni boucles multiples ( boucles multiples je ne le passe pas dans les tests IDE donc ok … ) mais mode casseur et mouvements simples, je les passe tous… Qu’y a t-il avec l’étape de validation ?

Utilise la sortie d’erreur standard pour débuguer et regarder ce qui se passe et à quel moment ça coince.
J’ai pu ainsi résoudre la manière de gérer les boucles qui faisait planter le test de la bibine.

Les tests de validation différent des tests de l’ide, il est donc normal que tu puisses avoir des résultats différents pour des tests ayant la même description, même si les tests de l’ide sont censés t’aiguiller vers la résolution de bug.

Sinon, effectivement, comme le dit nicolas_patrois, utilise la sortie d’erreur standard avec différents tests, affiche le labyrithe, les informations concernant chaque étape, et aide toi de la description des tests que tu ne passes pas pour deviner quel labyrinthe créer pour tes tests manuels.

En ultime recours, publie le code sur ideone.com, et envoie moi un mail (comtealexis[at]gmail[dot]com).

Bonjour à tous. Je crois que je suis dans la même situation. Je passe tous les tests en IDE, et la publication ne valide pas les tests “simples mouvements” ni “mode casseur”, qui sont parmi les plus simples. Je vais chercher un peu plus et je reviens ici si je trouve d’où vient le soucis.
A+

I guess I found why some guys passed all the validation test cases except the first simple one. You have to make sure that your code pass the following tricky case

####
#@$#
####
9 Likes

Hi.
Thanks, i think this test make me pass the “simple movement” test. I had a bad choice too in the “Broker” test. So 100% now. Thx for help.

Solved ! See eng_nabilion555 post.

Hahaah even I thought of this too :smiley: But then I realised its not in the spirit of learning so :stuck_out_tongue: ditched the idea

Thanks a lot I never realized there can be more than 1 previous state :sweat_smile:

Okay I was on 83% and the I solved the LOOP validation and now I am stuck on 92%. I cant seem to pass the All together validation case.It passes the testcase but not the validation.

2 Likes

I use Python 3. My program does not pass the second test, why this result wrong? Third test (‘Priorities’), for example, is succesful

1 Like

Why “west” after “north”?

you go south, then east3, then north, then west3 = you return to starting point!
isn’t this weird?

You misunderstood the puzzle statement. When Bender needs to change direction, he always tries them in the same order whatever his current direction is. So in test 2:

  • he goes south until first wall
  • then he can’t go south so he goes east until second wall
  • then he can go south so he does go south until third wall
  • then as step 2, he goes east until fourth wall
  • and finally he can go south to the target
9 Likes

I seem to be stumped at the last testcase. For some reason, I follow the exact same steps as the expected result, until step 151 where I find the destructible wall at 6,20 is still there (and I’m not in breaker mode) and the expected result walks right through.
If for some reason I ignore the beer at 9,2 all is well, but that’s not the right thing to do :smile:
What am I missing? I have a step-by-step log of everything that happens (http://pastebin.com/WFkyDCXF), but I can’t find a fault in it.
(Coordinates are 0-based)
(Also…might be related, my code fails validation for the last 2 tests after submitting).

Edit: Ok, I figured it out…subtle but still my mistake. I neglected to follow one part of instruction regarding the consumption of beer. “The beers remain in place after Bender has passed.”

1 Like

Hello,

Really strange I succeed all the tests in the editor but when I submit the test “Simple Move” failed.

Anyone can submit his solution to see if he have the same problem ?
I also valid the two tests given in the subject.

Thanks.

The test cases are only some random samples. Passing them doesn’t mean your algorithm will pass all other possible random samples.

The validation test cases are just another set of random samples. Your algorithm has a bug as long as any test case fails. It might even contain bugs when you pass all validation test cases.

Yes I know that tests may differ from the IDE tests, I checked again my code and read carefully the problem.

But same result, does anyone succeed to get 100% now? Or any idea what I should check?