Question: Progamming Language: Python 5. [Programming] (25pts) You're trapped in the bottom-left corner of a w h escape room, and need to cross to the door

 Progamming Language: Python 5. [Programming] (25pts) You're trapped in the bottom-left

Progamming Language: Python

5. [Programming] (25pts) You're trapped in the bottom-left corner of a w h escape room, and need to cross to the door in the upper-right corner to escape. But, the door will only unlock if you follow the correct path. Fortunately, you have directions for the path to follow across the grid cells on the floor, but the directions are incomplete. The partial path is represented as a string composed of the following characters {'U', 'D', 'L', 'R', '?'}, where each character represents a direction to take along the grid: U = up, D = dowm, L you must figure out. You know that the path may not cross the same grid cell twice. = left, R = right. The question marks represent unknown steps that Write a function CompletePath(s, w, h) that takes in three arguments: a string s representing the partial path, and two integers w and h specifying the room size. Your 3 function should return a string that represents the completed path, with all question marks filled in with the correct directions to take you from the bottom-left corner of the grid to the upper-right corner. If no path is possible, your function should return None. Your function should properly error-check all arguments. For example: in a 5 5 room, if s return the completed path to exit the room, "URDRRUUUUR". = "URD?RUU?UR" then your function should Here are a few sample test cases: CompletePath ("?RDRR?UUUR", CompletePath ("UURDD?UUR?RR", 6, 4) 5, 5) "URDRRUUUUR" "UURDDRUURURR" Complete this function in the iPython notebook

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!