-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.test.ts
44 lines (39 loc) · 1.63 KB
/
index.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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { getInput } from '../../../utils/file.ts';
import type { Slope } from './index.ts';
import { part1, part2 } from './index.ts';
const exampleInput = `..##.........##.........##.........##.........##.........##.......
#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.##.......#.##.......#.##.......#.##.......#.##.....
.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........#.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...##....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#`.split('\n');
const input = (await getInput(import.meta.dirname)).split('\n');
describe('Day 3', () => {
describe('Part 1', () => {
it('should return number of trees', () => {
const slope: Slope = [3, 1];
assert.strictEqual(part1(exampleInput, slope), 7);
assert.strictEqual(part1(input, slope), 145);
});
});
describe('Part 2', () => {
it('should return number of trees on all slopes', () => {
const slopes: Slope[] = [
[1, 1],
[3, 1],
[5, 1],
[7, 1],
[1, 2],
];
assert.strictEqual(part2(exampleInput, slopes), 336);
assert.strictEqual(part2(input, slopes), 3424528800);
});
});
});