Skip to content

Instantly share code, notes, and snippets.

@iammateus
Created July 5, 2022 15:21
Show Gist options
  • Save iammateus/3afd8640d7d65fd40de6db5c99dc8b1b to your computer and use it in GitHub Desktop.
Save iammateus/3afd8640d7d65fd40de6db5c99dc8b1b to your computer and use it in GitHub Desktop.
import removeIslands from '../../src/remove-islands';
describe('removeIslands', () => {
it('should work 1', () => {
expect(removeIslands([
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 0],
[1, 1, 0, 0, 1, 0],
[1, 0, 1, 1, 0, 0],
[1, 0, 0, 0, 0, 1],
])).toMatchObject([
[1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 1, 0],
[1, 1, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 1],
]);
});
it('should work 2', () => {
expect(removeIslands([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
])).toMatchObject([
[1, 0, 0],
[0, 0, 0],
[0, 0, 1],
]);
});
it('should work 3', () => {
expect(removeIslands([
[1, 1, 0],
[0, 1, 0],
[0, 1, 1],
])).toMatchObject([
[1, 1, 0],
[0, 1, 0],
[0, 1, 1],
]);
});
it('should work 4', () => {
expect(removeIslands([
[1, 1, 1],
[1, 1, 1],
[1, 1, 1],
])).toMatchObject([
[1, 1, 1],
[1, 1, 1],
[1, 1, 1],
]);
});
it('should work 5', () => {
expect(removeIslands([
[1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 1, 0],
])).toMatchObject([
[1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 1, 0],
]);
});
it('should work 6', () => {
expect(removeIslands([
[1, 1, 1, 1, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
])).toMatchObject([
[1, 1, 1, 1, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
]);
});
it('should work 7', () => {
expect(removeIslands([
[0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
])).toMatchObject([
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
]);
});
it('should work 8', () => {
expect(removeIslands([
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
])).toMatchObject([
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
]);
});
it('should work 10', () => {
expect(removeIslands([
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 0, 1, 1],
[0, 1, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 1, 0],
[0, 0, 0, 0, 1, 0],
])).toMatchObject([
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 0, 1, 1],
[0, 1, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 1, 0],
]);
});
it('should work 11', () => {
expect(removeIslands([
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
])).toMatchObject([
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
]);
});
it('should work 12', () => {
expect(removeIslands([
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
])).toMatchObject([
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
]);
});
it('should work 13', () => {
expect(removeIslands([
[1, 0, 0, 0, 0, 1],
[0, 1, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 1],
])).toMatchObject([
[1, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 1],
]);
});
it('should work 14', () => {
expect(removeIslands([
[1, 0, 0, 1, 0, 1],
[0, 1, 0, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0],
[1, 1, 0, 0, 0, 1],
])).toMatchObject([
[1, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[1, 1, 0, 0, 0, 1],
]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment