@finding-islands/core
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Finding Islands, Core

This package implements the algorithms to find the islands in a sea.

The sea is a bi-dimensional array of integers. Water is represented by the value 0.

An island is an array of coordinates.

Example

findIslands([
  [land, land, water, land, water],
  [water, land, water, land, land],
  [water, land, land, water, water],
  [land, land, water, water, land]
]);
[
  ([
    { x: 0, y: 0 },
    { x: 0, y: 1 },
    { x: 1, y: 1 },
    { x: 2, y: 1 },
    { x: 2, y: 2 },
    { x: 3, y: 0 },
    { x: 3, y: 1 }
  ],
  [{ x: 0, y: 3 }, { x: 1, y: 3 }, { x: 1, y: 4 }],
  [{ x: 3, y: 4 }])
];

Readme

Keywords

Package Sidebar

Install

npm i @finding-islands/core

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

25.8 kB

Total Files

27

Last publish

Collaborators

  • marcusmonteirodesouza