-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay08Test.groovy
68 lines (56 loc) · 2.01 KB
/
Day08Test.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
package be.vreijsenj.aoc.days
import spock.lang.Specification
class Day08Test extends Specification {
def "returns the number of steps to reach ZZZ"() {
given: "the map instructions"
def input = [
"LLR",
"",
"AAA = (BBB, BBB)",
"BBB = (AAA, ZZZ)",
"ZZZ = (ZZZ, ZZZ)"
]
when: "the route is calculated"
def result = new Day08().runPartOne(input)
then: "the result matches the example answer"
result == 6
}
def "returns the number of simultaneous steps to reach *Z"() {
given: "the map instructions"
def input = [
"LR",
"",
"11A = (11B, XXX)",
"11B = (XXX, 11Z)",
"11Z = (11B, XXX)",
"22A = (22B, XXX)",
"22B = (22C, 22C)",
"22C = (22Z, 22Z)",
"22Z = (22B, 22B)",
"XXX = (XXX, XXX)"
]
when: "the route is calculated"
def result = new Day08().runPartTwo(input)
then: "the result matches the example answer"
result == 6
}
def "returns correct direction for step"() {
given: "the map instructions"
def input = [
"LLR",
"",
"AAA = (BBB, BBB)",
"BBB = (AAA, ZZZ)",
"ZZZ = (ZZZ, ZZZ)"
]
when: "the network is constructed"
def network = Network.parse(input)
then: "the step is calculated correctly"
network.getDirection(1) == Direction.LEFT
network.getDirection(2) == Direction.LEFT
network.getDirection(3) == Direction.RIGHT
network.getDirection(16) == Direction.LEFT
network.getDirection(17) == Direction.LEFT
network.getDirection(18) == Direction.RIGHT
}
}