-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay18Test.groovy
90 lines (74 loc) · 2.76 KB
/
Day18Test.groovy
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
package be.vreijsenj.aoc.days
import spock.lang.Specification
class Day18Test extends Specification {
def "returns the amount of cubic meters of lava that can be held"() {
given: "the dig plan"
def input = [
"R 6 (#70c710)",
"D 5 (#0dc571)",
"L 2 (#5713f0)",
"D 2 (#d2c081)",
"R 2 (#59c680)",
"D 2 (#411b91)",
"L 5 (#8ceee2)",
"U 2 (#caa173)",
"L 1 (#1b58a2)",
"U 2 (#caa171)",
"R 2 (#7807d2)",
"U 3 (#a77fa3)",
"L 2 (#015232)",
"U 2 (#7a21e3)",
]
when: "the drill goes brrrr"
def result = new Day18().runPartOne(input)
then: "the result matches the example answer"
result == 62
}
def "returns the amount of cubic meters of lava that can be held from hex"() {
given: "the dig plan"
def input = [
"R 6 (#70c710)",
"D 5 (#0dc571)",
"L 2 (#5713f0)",
"D 2 (#d2c081)",
"R 2 (#59c680)",
"D 2 (#411b91)",
"L 5 (#8ceee2)",
"U 2 (#caa173)",
"L 1 (#1b58a2)",
"U 2 (#caa171)",
"R 2 (#7807d2)",
"U 3 (#a77fa3)",
"L 2 (#015232)",
"U 2 (#7a21e3)",
]
when: "the drill goes brrrr"
def result = new Day18().runPartTwo(input)
then: "the result matches the example answer"
result == 952408144115
}
def "reads the instructions from hex value"() {
given: "some hexadecimal dig instructions"
def start = new Hole(0, 0)
def input = [
"R 6 #70c710",
"D 5 #0dc571",
"L 2 #5713f0",
"D 2 #d2c081",
"R 2 #59c680"
]
when: "the instructions are parsed"
def result = input.collect { ColorEdge.parseFromHex(it, start) }
then: "the length and directions are clear"
result[0].start == new Hole(0, 0)
result[0].end == new Hole(461937, 0)
result[1].start == new Hole(0, 0)
result[1].end == new Hole(0, 56407)
result[2].start == new Hole(0, 0)
result[2].end == new Hole(356671, 0)
result[3].start == new Hole(0, 0)
result[3].end == new Hole(0, 863240)
result[4].start == new Hole(0, 0)
result[4].end == new Hole(367720, 0)
}
}