Go through the maze

    A cell labyrinth is a rectangle of square rooms, between some of them there are partitions.
    UFO threw you into the cell labyrinth MxN (M and N are known), without inputs and outputs. There is a prize in one of the rooms.
    You have as much time and memory as you like. Your goal is to get to the prize. It is guaranteed that this can be done.
    What are you going to do?
    UPD : my apologies, the options suggested by Tails and Brotherofken indicated that I was mistaken in reformulating.
    Canonically, it was necessary to create a program for a robot that can only walk - forward, backward, right, left. He doesn’t know how to check the conditions, he doesn’t even notice that he has hit the wall, he won the prize too. It is necessary to draw up a program (of finite length), acting on which he is guaranteed to visit the cage with a prize and stop.

    Also popular now: