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.

stromboli
Stromboli is a small volcanic island in the Tyrrhenian Sea and is part of the Aeolian or Lipari Islands, a volcanic archipelago north of Sicily, Italy. The island has an area of 12.6 square kilometres and is 918 metres high.
iberisch schiereiland
The Iberian Peninsula is a part of Europe that is located south of the Pyrenees. The peninsula is surrounded by the Mediterranean Sea, the Atlantic Ocean and the Bay of Biscay. The area is 582,530 kmĀ².

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.txt1, landmass2.txt2 and landmass3.txt3 are in the current directory.

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

>>> landtype('landmass1.txt7')
'island'
>>> landtype('landmass2.txt8')
'peninsula'
>>> landtype('landmass3.txt9')
'mainland'
>>> landtype('landmass3.txt10', ratio=0.2)
'peninsula'