Question: Question 1. The Maze Runner [40 pts] A robot is put in a maze where it can only take a single step of length1 at
![Question 1. The Maze Runner [40 pts] A robot is put](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2d7a491c5c_94866f2d7a4269df.jpg)
Question 1. The Maze Runner [40 pts] A robot is put in a maze where it can only take a single step of length1 at a time. The step must be in one of the four following directions: up, steps in form of a string is provided to the robot so that it can find the right way to go through the maze. The string consists of a combination of directions of each step the robot has to take. That is: n, left, or right. Based on the structure of the of maze, a A character u' or 'U" indicates taking a step up . A character'd or 'D indicates taking a step down . A character 'l' or U indicates taking a step to the left . A character or 'R indicates taking a step to the right For example, an input string 'RuLUrd' indicates that the robot must first take a step to the right, then a step up, then a step to the left, then a step up, then a step to the right and finally a step down in order to exit the 1 Modify the function step-count (Jin file hw4. py so that this function takes the nstruction string as input and returns the number of steps the robot has to take in order to go through the maze. Example: step_count"LRIURRDu) 2 8 2. Modify the function distance() n file hv4.py so that this function takes the instruction string as input and returns the distance (rounded to four decimal digits) between where the robot starts and the exit of the maze. Example: distance( LRURRDu') 2 1.4142 You can assume that the inputs for both the function are always a string. However, if that input string consists of an invalid character, which is a character not in the set of 'r','R,,'L','u','U, 'd', 'D'), both of the above functions must return -1 Example: i step count("7LRURRDu a distance ('aLRIURRDu") For distance calculation, we accept error within the range 1-0.0001, +0.0001 so you don't have to worry about the error in rounding up or down
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
