-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
96 lines (77 loc) · 2.04 KB
/
test.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const assert = require('assert');
const chronalCalibration = require('./chronal-calibration');
const chronalCalibration2 = require('./chronal-calibration2');
describe('Day 1: Chronal Calibration', () => {
it('should calculate frequency from +1, -2, +3, +1', () => {
const changes =
`+1
-2
+3
+1`;
assert.strictEqual(chronalCalibration(changes), 3);
});
it('should calculate frequency from +1, +1, +1', () => {
const changes =
`+1
+1
+1`;
assert.strictEqual(chronalCalibration(changes), 3);
});
it('should calculate frequency from +1, +1, -2', () => {
const changes =
`+1
+1
-2`;
assert.strictEqual(chronalCalibration(changes), 0);
});
it('should calculate frequency from -1, -2, -3', () => {
const changes =
`-1
-2
-3`;
assert.strictEqual(chronalCalibration(changes), -6);
});
describe('Part Two', () => {
it('should calculate first duplicate frequency from +1, -2, +3, +1', () => {
const changes =
`+1
-2
+3
+1`;
assert.strictEqual(chronalCalibration2(changes), 2);
});
it('should calculate first duplicate frequency from +1, -1', () => {
const changes =
`+1
-1`;
assert.strictEqual(chronalCalibration2(changes), 0);
});
it('should calculate first duplicate frequency from +3, +3, +4, -2, -4', () => {
const changes =
`+3
+3
+4
-2
-4`;
assert.strictEqual(chronalCalibration2(changes), 10);
});
it('should calculate first duplicate frequency from -6, +3, +8, +5, -6', () => {
const changes =
`-6
+3
+8
+5
-6`;
assert.strictEqual(chronalCalibration2(changes), 5);
});
it('should calculate first duplicate frequency from +7, +7, -2, -7, -4', () => {
const changes =
`+7
+7
-2
-7
-4`;
assert.strictEqual(chronalCalibration2(changes), 14);
});
});
});