Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions