-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd5.test.ts
93 lines (73 loc) · 1.52 KB
/
d5.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
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
import { describe, expect, it } from 'bun:test'
import { part1, part2 } from './d5'
import { readInput } from '../utils/fs'
describe('d5:p1', () => {
it('should solve example case', () => {
const input = `seeds: 79 14 55 13
seed-to-soil map:
50 98 2
52 50 48
soil-to-fertilizer map:
0 15 37
37 52 2
39 0 15
fertilizer-to-water map:
49 53 8
0 11 42
42 0 7
57 7 4
water-to-light map:
88 18 7
18 25 70
light-to-temperature map:
45 77 23
81 45 19
68 64 13
temperature-to-humidity map:
0 69 1
1 0 69
humidity-to-location map:
60 56 37
56 93 4`
expect(part1(input)).toEqual(35)
})
it('should solve puzzle input', async () => {
const input = await readInput('d5.txt')
expect(part1(input)).toEqual(227653707)
})
})
describe('d5:p2', () => {
it('should solve example case', () => {
const input = `seeds: 79 14 55 13
seed-to-soil map:
50 98 2
52 50 48
soil-to-fertilizer map:
0 15 37
37 52 2
39 0 15
fertilizer-to-water map:
49 53 8
0 11 42
42 0 7
57 7 4
water-to-light map:
88 18 7
18 25 70
light-to-temperature map:
45 77 23
81 45 19
68 64 13
temperature-to-humidity map:
0 69 1
1 0 69
humidity-to-location map:
60 56 37
56 93 4`
expect(part2(input)).toEqual(46)
})
it('should solve puzzle input', async () => {
const input = await readInput('d5.txt')
expect(part2(input)).toEqual(78775051)
})
})