Question: def update_elevation(elevation_map: List[List[int]], start: List[int], stop: List[int], delta: int) -> None: Modify elevation map elevation_map so that the elevation of each cell between cells start

def update_elevation(elevation_map: List[List[int]], start: List[int],

stop: List[int], delta: int) -> None:

"""Modify elevation map elevation_map so that the elevation of each

cell between cells start and stop, inclusive, changes by amount

delta.

Precondition: elevation_map is a valid elevation map.

start and stop are valid cells in elevation_map.

start and stop are in the same row or column or both.

If start and stop are in the same row,

start's column <=stop's column.

If start and stop are in the same column,

start's row <=stop's row.

elevation_map[i, j] + delta >= 1

for each cell [i, j] that will change.

>>> THREE_BY_THREE_COPY = [[1, 2, 1], [4, 6, 5],[7, 8, 9]]

>>> update_elevation(THREE_BY_THREE_COPY, [1, 0], [1, 1], -2)

>>> THREE_BY_THREE_COPY

[[1, 2, 1], [2, 4, 5], [7, 8, 9]]

>>> FOUR_BY_FOUR_COPY = [[1, 2, 6, 5],[4, 5, 3, 2], [7, 9, 8, 1], [1, 2, 1, 4]]

>>> update_elevation(FOUR_BY_FOUR_COPY, [1, 2], [3, 2], 1)

>>> FOUR_BY_FOUR_COPY

[[1, 2, 6, 5], [4, 5, 4, 2], [7, 9, 9, 1], [1, 2, 2, 4]]

"""

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 Programming Questions!