Question
PYTHON CODING HELP. part 1 :( Requirements/restraints for project is pictured in the screenshot. so is the map that is refeered to. For a project
PYTHON CODING HELP. part 1 :(
Requirements/restraints for project is pictured in the screenshot. so is the map that is refeered to. For a project I need to do these tasks
Function 1:
def show(map):
#given a map, create and return a string that when printed is formatted like the example (provided below) in a multi-line output containing only digits and spaces
function does not need to be called by any others, but is useful when testing other definitions manually)
values in the same row are separated by a single space
each value uses just enough characters for the LARGEST VALUE IN THE ENTIRE MAP, by using extra spaces to the left of any number that didnt take as many spaces to print. If everythings the same number of digits, we wouldnt need any of these extra spaces.
Each line ends with a digit from the last column, and then a newline, without any extra spaces.
Assume: map is a map as defined above.
Show ([[1, 2, 5], [ 10, 11, 8]]) --> 1 2 5 10 11 8
>>> print(show([[1, 2, 5], [ 10, 11, 8]]))
1 2 5
10 11 8
>>>
# 11 is the biggest number; it needs two columns to display, so all numbers need two
# characters in this case, single- digit numbers needed a single leading space.
Function 2:
def highest_point(map): Given a map, where is the highest point of land? If there is no land, return None. Otherwise, respond with a tuple of the row and column where we can find the highest point (dont use any negative indexes in answer). If there is a tie, return the location with the lowest row-index, and the lowest column-index as a further tie breaker. (the earlier row wins, and in further ties the earlier column wins).
Assume: map is a map as defined above
highest_point([[0, 0, 0], [0, 0, 0]] --> None
highest_point([[2, 5, 1], [9, 7, 6]] --> (1, 0) # row 1, column 0 has the highest land.
Highest_point([[1, 6, 1], [6, 2, 3]] --> (0, 1) # 6 is the highest land; first occurrence at (0, 1)
Function 3:
def on_map(map, r, c): Given a map and candidate location (the row/column indexes), is that position on the map? (remember, we only accept non-negative values for valid indexes).
Assume: map is a map as defined above, and r and c are int values.
on_map([[4,5,6],[7,8,9]], 0, 0) True # holds the value 4
on_map([[4,5,6],[7,8,9]], 2, 3) False # row too big; column too big
on_map([[4,5,6],[7,8,9]], -1, 1) False # no negatives allowed
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started