Blunder - Episode 1 - Puzzle discussion

Feel free to send your feedback or ask some help here!

Who was the game “Bender, a depressed robot?” Map “Broken wall?”
[18:39] In my opinion there is a mistake.

Hi,
What do you mean by “who was the game “Bender, a depressed robot?” Map “Broken wall?””?
If you’re saying that the test is wrong, normally it shouldn’t, and I can pass this test with my code.
Can you provide more informations if you’re doubting the validity of this test (programming language, maybe explaining quickly without spoil the solution (do not include code)) ?

Thanks in advance

All right. It’s my fault. Misunderstood the task.
I do not know much English, and the translator is not always the correct translation.

Sorry …

There is no problem about asking questions :wink:
Good luck for solving this task !

Keep coding!

2 Likes

Ok, i solved this. Bender got all but two suicide booths. I hope he met Fry there!

“Bite my shiny metal ass, meatbags!!!” © Bender

Please don’t get offended, i’m a big fan of Futurama and it’s just a quote:)

Incremental way of building functionality doesn’t work for me at all - i have a lot of smelling code in the end. Write code that passes first test case, then write code that will pass second test case, but don’t refactor. Well, that’s my curiosity on what’s ahead :slight_smile:

The only useful thing i wrote for this challnge is bidirectional dictionary type. It’s a list of pairs, and you can use it as dictionary by either key (returning a value) or by value (returning a key). I needed those to keep two-way relation between char (’#X@$SEWNTIB’) and a enum type representing a tile on a map.

I used very simple solution for loops - if tile was already visited for 5 times (i know, i know), it’s a loop, do nothing. Probably it’s the reason i get 100% but puzzle page isn’t updated?
UPD, it’s not, i was rated 100% after some time.

Could anyone please share your thoughts on loops?

Thanks Codingame, now i know for sure that

“Programming is fun!” © Codingame

I did so : if bender goes on a cell with the same status (Inverted / Breakermode) and direction than previouly, it is a loop. Of course if the map changes (wall break), you have to clear the traces.

6 Likes

I can’t get 100%.
In tests i passed all 12 tests, but when i click on “Submit” - i get only 91% without “LOOP”.
Why it happen?

As we don’t know what is your problem, is it hard to say, but if you can’t pass “LOOP” that mean that you didn’t handle LOOP case efficiently. As said numerous times: submit tests cases slightly differs from normal tests cases. Try implementing one of the idea spoken above to check efficiently for a loop case.

I finally got 100%.
But got it in very weird way: I commented part of code where bender must turn NORTH->WEST(in normal mode) and EAST->SOUTH(in inverse mode).
)))
Maybe i did not understand something in this quest.

You intrigued me.

How you then pass tests where there are inverters / NSWE modifiers?O_o

1 Like

Of course if Bender saw modifiers(NSWE) he will turn.
I commented code where Bender saw wall(#,X) and must turn NORTH->WEST(in normal mode) and EAST->SOUTH(in inverse mode).

I still don’t get it.
What does bender do when he sees a wall then?

Let’s not flood here, congrats on 100% :wink:

1 Like

Can’t we see the log of final tests ?
My program passes all the development tests. When I submit it passes all the final tests except the first (the simple one).
I can’t see why !

1 Like

I need a help. I can not solve LOOP (85 pts) test case on submition. Loop test case from basic test I can pass.

I’m not sure what I’m doing wrong. The main idea how I detect loops is something like:

  • I have matrix [C, L] of Lists of Bender states when he reach some position (Y, X)
    c# something like List[,]
  • Bender state is defined by four parametres Direction, HasBeer, Inverted and BrokenValsCounter (how many walls Bender crashed while getting into position because path after can change depending if there is some space where used to be wall)
  • When I try to move to some new position I calculate next bender state and check if he already was in that position in that state. If he was, I try next move depending on other parameters (inverted, etc)
    – if Bender can not move in current position (all around him are walls, invalid positions, already visited [with same state] fields, etc) I declare Bender is in loop and exit program

I can not spot where I make mistake. Can someone give me a little hint or something?

1 Like

Your representation of a state is correct and you should be able to detect a LOOP. Are you sure to store all the previous states for a given position (there could be more than 1 previous state for a position) ?

1 Like

Yes, that the whole point, I can not see what I’m doing wrong. Right now I’m thinking I have some stupid mistake but not sure how other cases works well.

this structure I am using for states (C#):

List[,] mapState = new List[L,C];

Check if possible and update func:

(state, p) => {
                List<BenderState> bss = mapState[p.Y,p.X];                
                var rv = bss.Exists(x => x.IsSameAs(state));
                if (!rv) {
                    bss.Add(state.Clone());
                    return true;
                }
                return false;
}

IsSameStateAs (in blenderState class)

public bool IsSameAs(BenderState other) {
            return HasBeer == other.HasBeer && Inverted == other.Inverted &&
                   Dir == other.Dir && BrokenValsCounter == other.BrokenValsCounter;
}

Clone method and constructor:

 public BenderState Clone() {
            return new BenderState(this);
}


 public BenderState(bool hasBeer, bool inverted, Direction dir) {
            HasBeer = hasBeer;
            Inverted = inverted;
            Dir = dir;
            BrokenValsCounter = 0;
        }

public void From(BenderState other) {
            HasBeer = other.HasBeer;
            Inverted = other.Inverted;
            Dir = other.Dir;
            BrokenValsCounter = other.BrokenValsCounter;
        }
public BenderState(BenderState other) {
            From(other);
        }
        

Your code doesn’t handle the following: :wink:

But I memorized List of states in one position, that is why  List < BenderState > [,] mapState and not just BlenderState[,]. It is multidimensional array (L * C) of lists of bender states.
Maybe has beer. inverted, direction and how many walls did he brake are not the only properties that are important. Maybe some other?

I only used these properties in my code, and it was fine.
Can you paste your code in a pastebin (pastebin.com) with option “Paste Exposure” set to “unlisted”, then send the link to coders[at]codingame[dot]com?

Thanks in advance