{"repo":"Gagniuc/Count-islands-and-calculate-their-percentage-coverage","free":true,"listed":false,"github":"https://github.com/Gagniuc/Count-islands-and-calculate-their-percentage-coverage","clone":"git clone https://github.com/Gagniuc/Count-islands-and-calculate-their-percentage-coverage.git","description":"This example detects and labels islands in a 2D grid, calculating their percentage coverage. It demonstrates recursion, array traversal, and formatted output, with applications ranging from image analysis to colony detection.","language":"JavaScript","stars":22,"topics":["2d","algorithm","colony","counter","coverage","detection","grid","image","island","matrices"],"license":"MIT","category":"self-hosted-apps","readme_excerpt":"Count islands and calculate their percentage coverage Ex. (213) - Count islands and calculate their percentage coverage , is presented here in three programming languages: Python , MATLAB , and JavaScript . Although the implementations differ in syntax, the underlying concept remains identical across all three versions. Each code sample is reproduced from its respective volume of the series Coding Examples from Simple to Complex (Springer, 2024). This source code defines a program that processes a 2D array a representing a grid of land and identifies and labels islands on the grid. The code begins by defining a 2D array a , which represents a grid of land with 1s representing land and 0s representing water. Another 2D array b is defined, which represents directional offsets. Each element in b is a pair of coordinates that represent movement in different directions (right, left, up, down, etc.). An array q is defined, containing various characters used to label the islands on the grid (more than before). An empty 2D array p is created to store information about the islands. Next, the code calls the SCAN(a) function, which scans the grid to identify and label the islands. It then prints the number of islands found and two representations of the grid: the original grid with islands labeled and a grid representation of island information (please see the output above). Inside, the SCAN(a) function scans the entire grid, calling d(a, i, j, n, m, c) when it encounters a land element","default_branch":null,"files":null,"tree":[],"storefront":"/r/Gagniuc","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/Gagniuc/Count-islands-and-calculate-their-percentage-coverage/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}