Question: from typing import List, Unionimport mathdef distance ( a: int, b: int, c: int, d: int ) - > float: ' ' ' returns the

from typing import List, Unionimport mathdef distance(a: int, b: int, c: int, d: int)-> float: ''' returns the Euclidean distance between locations (a,b) and (c,d).>>> distance(2,5,8,3)6.324555320336759>>> distance(12,5,15,1)5.0''' def is_safe(plant_row: int, plant_col: int, frog_map: List[List[int]])-> bool: ''' Returns True if building a plant at position (row,col) is safe, considering the given frog_map. Returns False otherwise >>> frog_map =[[0,0,0,0,0,0,0,0,0],\[0,0,0,1,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,1,0,0,1],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,1,1,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0]]>>> is_safe(5,1, frog_map) False >>> is_safe(10,4, frog_map) False >>> is_safe(10,0, frog_map) False >>> is_safe(8,7, frog_map) True >>> is_safe(10,5, frog_map) True ''' def number_safe_locations(frog_map: List[List[int]])-> int: ''' Returns the number of locations where a plant could be installed. >>> frog_map =[[0,0,0,0,0,0,0,0,0],\[0,0,0,1,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,1,0,0,1],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,1,1,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0],\[0,0,0,0,0,0,0,0,0]]>>> number_safe_locations(frog_map)22''' Pls rectify the solution. It passed only 20/35 tests

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!