Create a function that takes a matrix as an argument and returns the number of "islands" in the matrix, as well as the quantity of "islands" by type.
nxm elements.0) or land (1).1, connected horizontally or vertically (not diagonally).Finally, the program must calculate the number of islands by type:
Type of Island | Abbreviation for Output | Number of Lands --- | --- Micro | Mic | 1 | Small | Sml | >1 and <= 3 | Medium | Med | >3 and <=5 | Big | Big | >5 and <=9 | Massive | Msv | >9 |
islands([
[1, 0],
[0, 0],
])
➞
Tot Islands: 1
Mic Islands: 1
Sml Islands: 0
Med Islands: 0
Big Islands: 0
Msv Islands: 0
islands([
[1, 0, 1, 1],
[0, 1, 0, 1],
[0, 1, 0, 0],
[1, 1, 0, 1],
])
➞
Tot Islands: 4
Mic Islands: 2
Sml Islands: 1
Med Islands: 1
Big Islands: 0
Msv Islands: 0
N/A