Question: Python programming language is required for the solution !!!!! This is the second time I post this question, I hope to get an answer this
Python programming language is required for the solution
!!!!! This is the second time I post this question, I hope to get an answer this time!!!





A beast is in a labyrinth, which is represented as a rectangular grid. At any moment, the beast is at one particular position and is turned in one of four possible directions (up, down, left and right). In each round the beast makes one move: it will either turn left, turn right or take one step forward. At the beginning, the beast will always have a wall to its right. As the beast moves it tries to follow this wall at all times (see the sample output below). Standard input will contain an integer N on its own line, followed by a map of the labyrinth. Individual characters depict individual positions: 'x' is a wall and'.' is an empty spot. The characters '', '>', 'v' and 'X XXXXX XXXXX X...X X..^x XXXXX XXXXX X..^X X... XXXXX XXXXX X.... .... ...... XXXXXXXXXX XXXXXXXXXX ...... ... .3. .... X,X..... XXXXXXXXXX ....... x......> .... ...... ... .... x, .... v .... ...... XXXXXXXXXX ,...... ....... ...v ..... XXXXXXXXXX X....X... X....X...X X.X.X.X.X X.X....XvX XXXXXXXXXX XXXXXXXXXX X....X...X X....X...X X.X.X.X.X X.X....XXX XXXXXXXXXX XXXXXXXXXX X....X...X X....X...X X.X.X.X.X X.X....X^X XXXXXXXXXX XXXXXXXXXX X....X...X X. ...X... X.X.X.X^X X.X....X.X XXXXXXXXXX XXXXXXXXXX X....X...X X....X..^x X.X..X.X.X X.X....X.X XXXXXXXXXX Sample input #3: 3 XXXXXXXXXXXX X. ......... X.........^X XXXXXXXXXXXX Output: XXXXXXXXXXXX X.........^X X..... XXXXXXXXXXXX XXXXXXXXXXXX X.........''X XXXXXXX XXXXXXX X.X.X.X X.X.X.X X.<...x xxxxxxx x.x.x.x x x.....x hints: use input to read n then sys.stdin the maze. here is some pseudocode that explains how beast behaves: while true: if there an open space right: turn right walk forward else ahead: else: left you store maze as a list of strings can access each character however note are immutable. want be able modify characters in could convert row using function. back string join method will helpful. try avoid writing code repeated four times once for compass direction. it might helpful write classes pos and vec represent position vector these orientation. even magic __add__that lets add position. rotate dy degrees get dx i am assuming y-coordinates increase move downward which usual convention computer graphics.>