Question: def count_coastline(map): Given a map, how many spots are adjacent to water? Assume: map is a map as defined above, and r and c are
def count_coastline(map): Given a map, how many spots are adjacent to water? Assume: map is a map as defined above, and r and c are int values.
count_coastline(map1) 9
count_coastline(map2) 11
count_coastline([[1,1,1],[1,0,1],[1,1,1]]) 8
.|p4.pdf file//C/Users/62626/Desktop/CS112/Project4/p4,pdf Indexing into a Map When we have a map, we have two dimensions. The first dimension indicates the row (top row to bottom row), and the second dimension(0) indicates the column (left column to right column). Thus with N rows.. and M columns, we have a grid with indexes as shown to the right (0,0) (0M-1) (1M-1) Now we define some sample maps, which are used (by name) in examples through the descriptions in this document map2 [4,1,0, e,0,0,2], [1,0,8,10,0,0,11, mapi-[0,0,8,8,0], map3- 5,4,51, 1,2,11, map5 map4 [5,0,1,0,6], map6 [4,6,7,6,5,4], 9,0,8,9,0] [4,0,8,0,21, 9,0,8,8,0, [8,0,3,0,7] 1 [6,5,6,5,5,5], [6,5,3,4,5,6], [0,0,8,0,0,e], [8,8,8,8,8,6], [8,7,8,9,8,7, [8,8,8,8,8,6] e, 3, 5,12, 4, 1, e, 0] 0, 0, 1, 0, 0, e, e, 0]] map7 [0,0,8,8,e,], map8 [0,0,8,0,0,5,0,0], [0,5,8,0,5, [e,0,8,0,0,0], [0,5,8,0,5, [e,0,7,7,e,0], [0,6,0,8,6,e] 1 [0,0,8,0,4,0,8,], [0,0,8,0,0,0,8,8] [0,0,8,0,0,8,8,8 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
