Bender - Episode 1 - Puzzle discussion


It’s the second way.
And when he comes to the next Inverter, his preferences will reverse again (so he will go south).
If he comes to an Inverter he’s been to already the preference will always be set to default.


When attempting to pass the Obstacles test the expected behavior is different to what is in the task description:

Input (using dots instead of spaces):



    NORTH - test expects SOUTH at this point

Help, is the logic supposed to be inverted in some cases besides stepping on an I square?


No, it isn’t. When encountering an obstacle (He cannot go EAST), as per rule 4, he tries to go SOUTH first, then EAST, then NORTH, then WEST. Because he can go SOUTH in this scenario, he goes SOUTH.
He always tries SOUTH first, when he is not inverted.


Expected result:


As you can see there is no NORTH at all. So it is not like Bender is trying to go SOUTH and fails. He turns before going SOUTH again. It is as if the shortest path is described here instead of the simple: “go until you hit a wall, then turn, repeat”


Oh wait, do you mean he always starts with SOUTH when hitting a wall?


Yes, when not inverted, Bendy always tries to move SOUTH when hitting a wall.
The only time he would go WEST is in this constellation, if he went “EAST” into it:


(Can’t go SOUTH, can’t go EAST, can’t go NORTH, so he goes WEST)

Larger example:


Here, he would go
SOUTH (Obstacle)
EAST (Obstacle)
SOUTH (Obstacle, Obstacle)

He doesn’t go NORTH immediately when hitting the right wall, because he always goes SOUTH first. On the bottom right corner, he cannot go SOUTH, cannot go EAST, thus goes NORTH.


Thank you for the clarifications. This was unexpected as most bots depend on their current direction.


Hi, I got 100% but managed to cheat with the loop detection part. :slight_smile: . I just set a step counter and if it is over 1 000 000. I print “LOOP”
Even the validators accepted it! Maybe there should be a test case to counter this bypass


Finally solved this one to 100%.

My recommendations:

  1. Carefully examine that Bender enters the correct tile and retains the correct direction on each state transition.
  2. Bender starts his turn sequence FRESH with every wall collision. (as mentioned above.)
  3. Carefully differentiate between last state and current state.
  4. Maintain direction through the teleport
  5. Check for erroneous state updates / mutations that may have snuck into your code. (This is what got me. :man_facepalming:)

Since this puzzle is all about state machines, it naturally stresses a precise management of State & State History, Current State and Future State. I think this is a great puzzle, but debugging it is what catches most people. I literally had to go state change by state change to locate the bugs.

Good luck to anyone still struggling to debug their code! You may try what I did -> re-code from scratch in a different language! :sweat_smile:


i’m sorry, but i get stuck at the last testcase。he could pass the “T” ,finally he will drop into loop.what am i missing :rofl:, i can’t find a fault in it


Hi everybody ! I’m glad to share my very first comment on this forum :wink:

I validated all tests with two different solutions for ‘loop’ and ‘multiple loops ?’ : one hardcoded to stop while instructions (above 1 billion operations) and a more “elegant” one.

However, i then scored 91% : I didn’t succeed in ‘loop’ test…

I code in Python. Any idea of what’s happening… ?


Hey. Could someone help me out with a problem I’m facing.
I passed all the test cases in the IDE but on submitting i can’t pass the All Together validator.
Is someone facing a similar problem or knows how this can be fixed?


Hey dude, I have the same problem.
So far I’ve ruled that it’s not a LOOP, and that my program doesn’t send a fake “LOOP”. It must be an issue with the instructions we send out.
So far I’ve managed to reproduce the test in another environment, but I haven’t found a map with a problem yet. Maybe we should ask staff for help ?
I’ll keep you posted.


Looking at the validator, I’d bet you somehow implemented wrongly the inverter but can’t be sure so I’m sending you both the validator. @cclaude42 @Rhydberg
Feel free to share in this public thread what was the issue in your code once you find it.


Found the issue. If I was on a direction, like “N”, but there was an obstacle in front of me, I ignored the direction, and turned the wrong way.


Congratulations on 100% @cclaude42 . I found my bug too. It was just a silly little thing in my teleporter code. Thanks for the help @_CG_Thibaud !