Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function get_neighbors that returns a list of all neighbors for a given x and y coordinate. Neighbor must share an edge( no diagonal

Write a function get_neighbors that returns a list of all neighbors for a given x and y coordinate. Neighbor must share an edge( no diagonal moves). Make sure to only return valid nodes. That is, nodes that are within the bounds of the graph and arent a wall. image text in transcribed
image text in transcribed
right and y increases as you go down. As an example, the bold and underline 0 is at (2, o) For this assignment, you will write a function called get_neighbors(), which will return a list of all neighbors for a given x, y coordinate. Neighbors mush share an edge (ie no diagonal moves). Make sure to only return valid nodes. That is, nodes that are within the bounds of the graph and aren't a wall. get_neighbors() takes two arguments, the graph and a node The graph will be a list of lists, as in the example above. The node will be a tuple in the form (x, y). It should return a list of tuples Quick reminder on tuples: # how to make one node (4, 7) # how to access one node [0] node[1] Expected behavior # using the graph defined above neighbors get_neighbors (graph, (e, )) len(neighbors) 2 (e, 1) in neighborsTrue (1, 0) in neighbors-True- neighborsget neighbors(graphas Ien(neighbors) (4,1) in neighborsTrue (3, 0) in neighborsTrue 0 6:17 PM ds) 02/03/2019 ^ share your progrom enhance your work after submitting export to r back to classroom run run tests 1-bef get neighbors(graph, node)

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

What is the role of information in decision making?

Answered: 1 week ago

Question

LO1 Explain how the workforce is changing in unpredicted ways.

Answered: 1 week ago