TCS Code Vita Season-5 Round-1 set-1 Program-7

Problem : Continents and Oceans

There will be several continents on a world map. Idea is to identify the number of continents and the mass in each.

The land is denoted by ‘#’ and ocean by spaces. You have to find the number of continents (connected masses of land) and print the number of # in the continent. 

Connected mass of land means that # can be connected in any way i.e. horizontally, vertically or diagonally. 

Input Format: 
1.    Path to a file, for example /tmp/T1.txt
2.    This file contains 15 rows and 60 columns depicting a map. See Examples section below.

Output Format: 

Number of # per continent in descending order of size and total number of continents in the format depicted below 

Island 1: <Biggest mass> say 100
Island 2: <Smallest mass> say 50
Number of continents: 2 

Example 1: