-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day09Test.kt
52 lines (46 loc) · 1.73 KB
/
Day09Test.kt
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
package io.dmitrijs.aoc2017
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import kotlin.test.Test
import kotlin.test.assertEquals
@DisplayName("Day 9")
internal class Day09Test {
private val problemInput = Resources.resourceAsText("day09")
@Nested
@DisplayName("Puzzle 1")
inner class Puzzle1 {
@Test
fun `solves example`() {
assertEquals(1, Day09("""{}""").puzzle1())
assertEquals(6, Day09("""{{{}}}""").puzzle1())
assertEquals(5, Day09("""{{},{}}""").puzzle1())
assertEquals(16, Day09("""{{{},{},{{}}}}""").puzzle1())
assertEquals(1, Day09("""{<a>,<a>,<a>,<a>}""").puzzle1())
assertEquals(9, Day09("""{{<ab>},{<ab>},{<ab>},{<ab>}}""").puzzle1())
assertEquals(9, Day09("""{{<!!>},{<!!>},{<!!>},{<!!>}}""").puzzle1())
assertEquals(3, Day09("""{{<a!>},{<a!>},{<a!>},{<ab>}}""").puzzle1())
}
@Test
fun `solves problem`() {
assertEquals(9_662, Day09(problemInput).puzzle1())
}
}
@Nested
@DisplayName("Puzzle 2")
inner class Puzzle2 {
@Test
fun `solves example`() {
assertEquals(0, Day09("""<>""").puzzle2())
assertEquals(17, Day09("""<random characters>""").puzzle2())
assertEquals(3, Day09("""<<<<>""").puzzle2())
assertEquals(2, Day09("""<{!>}>""").puzzle2())
assertEquals(0, Day09("""<!!>""").puzzle2())
assertEquals(0, Day09("""<!!!>>""").puzzle2())
assertEquals(10, Day09("""<{o"i!a,<{i<a>""").puzzle2())
}
@Test
fun `solves problem`() {
assertEquals(4_903, Day09(problemInput).puzzle2())
}
}
}