Bender - Episode 1 - Puzzle discussion


#83

I think you just need to rethink this :slight_smile: you just got confused by numbers or spaces or I don’t know.
The test is correct, good luck!


#84

I hope someone’s still reading these, but can anyone explain WHY this case is tricky? I feed it into my algorithm and it posts a single move to the East and stops, yet the algorithm STILL won’t pass the first validation test. I have no clue why and without feedback as to WHY the code is failing, I can’t debug it.


#86

Maybe make sure your algorithm can solve single step solutions in all four directions?


#87

I actually just found my bug. I had an inversion in places that allowed it to work with the test cases. Took forever to track it down.


#88

Congrats on solving it! I had a hard time with it, but was really proud when I solved it.


#89

Hi,
This puzzle is advertised as 130 XP. I have 100% score, yet I’ve got 100 XP.
There are 2 achievements which both give 50 XP. Where is this extra 30 XP?
Thanks.


#90

Well spotted, I’ll look into it.

Edit: Problem Solved


#91

Hello ladies and gentlemen,

I have managed to pass all 11 test cases, but I am dead stuck with multiple loops. Could you tell me if there are flaws in my logic:

Basically, whenever Bender moves, I record his new position, states and direction in a separate Array. Before each move is recorded to this Array, I cross-check current position, state and direction of a Bender with the Array of previously visited places(position, state, direction). If there is a match, I take it for a loop. It works fine for a single loop, but it fails in multiple loops test. Can you share you thoughts, where is the flaw in my logic?

Thanks


#92

Hello ladies and gentlemen,

I have managed to pass all 11 test cases, but I am dead stuck with multiple loops. Could you tell me if there are flaws in my logic:

Basically, whenever Bender moves, I record his new position, states and direction in a separate Array. Before each move is recorded to this Array, I cross-check current position, state and direction of a Bender with the Array of previously visited places(position, state, direction). If there is a match, I take it for a loop. It works fine for a single loop, but it fails in multiple loops test. Can you share you thoughts, where is the flaw in my logic?

Thanks


#93

I am not sure if position, state and direction are enough, as you may have changed the map by breaking obstacles, and so even if you get back on the same position, state and direction you may not be in a infinite loop as you may pass through an obstacle you destroyed before.
You may add the number of obstacles present on the map in your array.
I can’t be 100% positive it will work as I bypassed this issue by counting the number of movement Bender made and when the number is too big I assumed I was in a loop.


#94

Thanks, I will think about this, but I personally think that adding the obstacles isn’t very important (at least that’s the first thought). You see, when Bender in Breaker mode walks over “X”, I update the “map”, by replacing “X” with " ", because the instruction says that the “X” is destroyed permanently. So even if I count obstacles, it is the same as if I was counting any other cell in the map. Bender will walk over it again if it is a loop, probably with the same states. This is my impression.

Or did you mean something else by “add the number of obstacles in your Array” ?


#95

And let’s not forget - I do get the “Loop” test correctly, the identification of a single loop works well. I only have problem with multiple loops, which makes me think that we need to assume that some if some amount of moves is used and “$” has not been reached, then we should consider it a multiple loop. But it doesn’t feel like the right decision :slight_smile:


#96

Are you checking for both his inverted state, and his breaker state?


#97

To detect this, I clear out my history array any time I break an obstacle.


#98

mixolyde way is good too.

What I meant by ‘your array’ was the array where you save the precedent places bender has been in which you attach the position the state and direction of bender, and I think you should add the number of obstacles you had on the map at this moment to those previous parameters.
Because for instance you may encounter an obstacle while moving from north to south and have to go away but after you may break it by moving from east to west with a beer state. Then if you are moving again from north to south toward the box, your program without a record of the number of obstacle associated with your position direction and status would assume you are in a loop although you may pass through the destroyed object.

I have to admit that counting the number of move was not a really beautiful solution, it is not really robust but it worked on the validators :slight_smile:


#99

Some way to track the state of the map is as important as anything else. Remember, to detect a loop, you need to know the state of the ENTIRE finite state machine, not just the state of Bender. The map is part of that FSM, so if the map has changed, then even if Bender returns to the same coordinates with the same breaker and inversion state, the MACHINE will be in a different state and a loop can’t be assumed.

Mixolyde’s solution is nice and elegant. The idea is to know if Bender’s state has ever repeated while the map is in its current configuration.


#100

Bonjour,

j’arrive à passer tous les tests mais après soumission, seul le 1 et le 11 sont ok, les autres échouent. Une idée ? Je peux également poster le code (bash)


#101

So I pass every test except the last one, where I am not getting LOOP outputs just wrong outputs.
When I submit I pass every test except the last one plus “breaker mode”. Can anyone tell me what I may be doing wrong since I somehow get home in the last test, somehow pass the main breaker mode, however not the Submit edition of the “breaker mode”.


#102

Nice solution! I passed 100% now, :slight_smile:


#103

Still having problems with the first validator. I’ve even tried having output “LOOP” or just the one move in case of 12 squares (cause you really can’t catch him in one step), without the 12 square validator that simple 3x4 outputs 2 moves. but no matter what i try, I can’t get past 92%, I even have a showMap in the BenderMap class, so I can show "B"ender everywhere he moves. LOL it’s a true state machine,

moves[]; index = 0; while(map.hasNext()) { moves[index] = map.getNext(); //save moves index++; map.showMap(); }

Fixed it. I’m mildly dyslexic, so I was testing if next spot is exit no more moves. I changed it to test this spot only for exit and boom, no need for 12 square check, cause big map all X’s just 2 spots @ and $ is same as 3X4, Works perfect.