An island is a piece of land that is surrounded on all sides by water. When a piece of land is not an island, because it is joined to the continent (small area compared to the size of the land), it is called a peninsula. In all other cases it is said that the land is part of the mainland.

stromboliiberisch schiereiland

Assignment

We'll work with text files, each containing a detail of a map. This detailed map is described on the basis of a number of text lines that all have the same length. The map contains a continental landmass of which pieces are marked with a hash (#) and a second land mass of which the parts are designated by the letter S. Pieces of sea are indicated by a space. Asked is to determine whether the land mass that is designated by the letters S is an island, a peninsula or part of the continent. To do this, just follow these steps:

Example

In the following interactive session we assume that the files landmass1.txt, landmass2.txt and landmass3.txt are in the current directory.

>>> landmass('landmass1.txt')
(0, 196)
>>> landmass('landmass2.txt')
(6, 169)
>>> landmass('landmass3.txt')
(8, 45)

>>> landtype('landmass1.txt')
'island'
>>> landtype('landmass2.txt')
'peninsula'
>>> landtype('landmass3.txt')
'mainland'
>>> landtype('landmass3.txt', ratio=0.2)
'peninsula'