advent-of-code-2023/src/day_eleven.test.ts

27 lines
740 B
TypeScript
Raw Permalink Normal View History

2023-12-11 08:58:55 +00:00
import {Observatory} from "./day_eleven";
describe('Observatory', () => {
const input = `...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....`;
it('should calculate the shortest path between every galaxy', () => {
const observatory = new Observatory(input);
expect(observatory.shortestPaths).toEqual(82000210);
});
it.each([
[[9, 0], [9, 4], 1_000_004],
[[0, 3], [8, 7], 3_000_012],
])(`should calculate the distance between two galaxies`, (galaxyOne, galaxyTwo, expectedDistance) => {
const observatory = new Observatory(input);
expect(observatory.distanceBetween(galaxyOne as [number, number], galaxyTwo as [number, number])).toEqual(expectedDistance);
});
});