-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.test.ts
33 lines (30 loc) · 1.11 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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { getInput } from '../../../utils/file.ts';
import { part1, part2 } from './index.ts';
const input = await getInput(import.meta.dirname);
describe('2015', () => {
describe('Day 1', () => {
describe('Part 1', () => {
it('should return floor number', () => {
assert.strictEqual(part1('(())'), 0);
assert.strictEqual(part1('()()'), 0);
assert.strictEqual(part1('((('), 3);
assert.strictEqual(part1('(()(()('), 3);
assert.strictEqual(part1('))((((('), 3);
assert.strictEqual(part1('())'), -1);
assert.strictEqual(part1('))('), -1);
assert.strictEqual(part1(')))'), -3);
assert.strictEqual(part1(')())())'), -3);
assert.strictEqual(part1(input), 280);
});
});
describe('Part 2', () => {
it('should return index of the first character to enter the basement', () => {
assert.strictEqual(part2(')'), 1);
assert.strictEqual(part2('()())'), 5);
assert.strictEqual(part2(input), 1797);
});
});
});
});