-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday15.test.ts
64 lines (55 loc) · 1.88 KB
/
day15.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { describe, expect, it } from 'vitest';
import { DayImpl, expandGrid } from './day15.ts';
const largerExample = `##########
#..O..O.O#
#......O.#
#.OO..O.O#
#O#..O...#
#O..O..O.#
#.OO.O.OO#
#....O...#
##########
<vv>^<v^>v>^vv^v>v<>v^v<v<^vv<<<^><<><>>v<vvv<>^v^>^<<<><<v<<<v^vv^v>^
vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<<v<^v>^<^^>>>^<v<v
><>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^<v>v^^<^^vv<
<<v<^>>^^^^>>>v^<>vvv^><v<<<>^^^vv^<vvv>^>v<^^^^v<>^>vvvv><>>v^<<^^^^^
^><^><>>><>^^<<^^v>>><^<v>^<vv>>v>>>^v><>^v><<<<v>>v<v<v>vvv>^<><<>^><
^>><>^v<><^vvv<^^<><v<<<<<><^v<<<><<<^^<v<^^^><^>>^<v^><<<^>>^v<v^v<v^
>^>>^v>vv>^<<^v<>><<><<v<<v><>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^
<><^^>^^^<><vvvvv^v<v<<>^v<v>v<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<>
^^>vv<^v^v<vv>^<><v<^v>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<><<v>
v^^>>><<^^<>>^v^<v^vv<>v^<<>^<^v^v><^<<<><<^<v><v<>vv>>v><v^<vv<>v^<<^
`;
describe('day15', () => {
describe('partOne', () => {
it('should return 2028 for smaller example', () => {
const sample = `########
#..O.O.#
##@.O..#
#...O..#
#.#.O..#
#...O..#
#......#
########
<^^>>>vv<v>>v<<`;
expect(new DayImpl(sample).partOne()).toEqual(2028);
});
it('should return 10092 for larger example', () => {
expect(new DayImpl(largerExample).partOne()).toEqual(10092);
});
});
describe('partTwo', () => {
it('should return', () => {
expect(new DayImpl(largerExample).partTwo()).toEqual(9021);
});
});
describe('expandGrid', () => {
it('should expand grid', () => {
const line = '#.........O#...O.OO.OO.O##OO..#..O#O.O.........O.#';
const grid = [line.split('')];
const expectedResult = '##..................[]##......[]..[][]..[][]..[]####[][]....##....[]##[]..[]..................[]..##';
expect(expandGrid(grid)[0].join('')).toEqual(expectedResult);
});
});
});