Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

R2-D2 navigates the grid thanks to you but is now facing a more hostile grid, one with obstacles represented by 1s. Use the same assumptions

R2-D2 navigates the grid thanks to you but is now facing a more hostile grid, one with obstacles represented by 1s. Use the same assumptions provided in Q1 and return the length of the shortest path avoiding obstacles. Return -1 if no such path exists.

Hints: 1. Dont explore neighbors that dont exist (are beyond the grids boundary) 2. Dont explore neighbors that are obstacles. 3. Your search ends when there is nothing to explore.image text in transcribed

grid = [[0,0,0], [1,1,0], [1,1,0]] start, goal = (0,1), (2,2) Solution = 4 grid = [[0,1], [1,01] start, goal = (0,0), (1,1) Solution = -1 ---> The R2-D2 can't travel diagonally and thus there doesn't exist any feasible path

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

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions