ideas-island
v1.1.0
Published
This JavaScript script calculates the area of an island represented by a matrix of 1s and 0s, where 1 represents land and 0 represents water.
Downloads
2
Readme
Island Area Calculator
This JavaScript script calculates the area of an island represented by a matrix of 1s and 0s, where 1 represents land and 0 represents water.
Usage
Clone the repository:
git clone [https://github.com/your-username/island-area-calculator.git](https://github.com/olegchobotar/ideas-island.git)
Navigate to the project directory:
cd ideas-island
Install dependencies (not required for this example, but your project may have dependencies in the future):
# This example doesn't have dependencies, but you may have them in your project
Run the script:
node island-calculator.js
Modify the
islandMatrix
variable inisland-calculator.js
to represent your own islands and run the script again.
Example
const islandMatrix = [
[1, 1, 0, 0, 1],
[1, 0, 0, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[1, 1, 1, 0, 1]
];
const area = calculateIslandArea(islandMatrix);
console.log('Island Area:', area);