File tree 6 files changed +84
-15
lines changed
6 files changed +84
-15
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ repositories {
14
14
15
15
dependencies {
16
16
testImplementation(kotlin(" test" ))
17
+ testImplementation(" org.junit.jupiter:junit-jupiter:5.8.1" )
17
18
}
18
19
19
20
tasks.test {
Original file line number Diff line number Diff line change @@ -48,22 +48,18 @@ fun String.parseResult() = when (this) {
48
48
else -> throw IllegalArgumentException (this )
49
49
}
50
50
51
- fun neededFor (result : Result , option : Option ) = when (result) {
52
- Lose -> option.strongAgainst()
51
+ fun neededFor (result : Result , option : Option ) = when (result) {
52
+ Lose -> when (option) {
53
+ Rock -> Scissors
54
+ Paper -> Rock
55
+ Scissors -> Paper
56
+ }
53
57
Draw -> option
54
- Win -> option.weakAgainst()
55
- }
56
-
57
- fun Option.weakAgainst () = when (this ) {
58
- Rock -> Paper
59
- Paper -> Scissors
60
- Scissors -> Rock
61
- }
62
-
63
- fun Option.strongAgainst () = when (this ) {
64
- Rock -> Scissors
65
- Paper -> Rock
66
- Scissors -> Paper
58
+ Win -> when (option) {
59
+ Rock -> Paper
60
+ Paper -> Scissors
61
+ Scissors -> Rock
62
+ }
67
63
}
68
64
69
65
fun day2part2 () = Files .lines(Paths .get(" input/2.txt" )).asSequence()
Original file line number Diff line number Diff line change
1
+ package days
2
+
3
+ import org.junit.jupiter.api.Test
4
+
5
+ import org.junit.jupiter.api.Assertions.*
6
+
7
+ internal class Day1Test {
8
+
9
+ @Test
10
+ fun day1part1Test () {
11
+ assertEquals(71300 , day1part1())
12
+ }
13
+
14
+ @Test
15
+ fun day1part2Test () {
16
+ assertEquals(209691 , day1part2())
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package days
2
+
3
+ import org.junit.jupiter.api.Test
4
+
5
+ import org.junit.jupiter.api.Assertions.*
6
+
7
+ internal class Day2Test {
8
+
9
+ @Test
10
+ fun day2Part1Test () {
11
+ assertEquals(14827 , day2Part1())
12
+ }
13
+
14
+ @Test
15
+ fun day2part2Test () {
16
+ assertEquals(13889 , day2part2())
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package days
2
+
3
+ import org.junit.jupiter.api.Test
4
+
5
+ import org.junit.jupiter.api.Assertions.*
6
+
7
+ internal class Day3Test {
8
+
9
+ @Test
10
+ fun day3part1Test () {
11
+ assertEquals(8233 , day3part1())
12
+ }
13
+
14
+ @Test
15
+ fun day3part2Test () {
16
+ assertEquals(2821 , day3part2())
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package days
2
+
3
+ import org.junit.jupiter.api.Test
4
+
5
+ import org.junit.jupiter.api.Assertions.*
6
+
7
+ internal class Day4Test {
8
+
9
+ @Test
10
+ fun day4part1Test () {
11
+ assertEquals(487 , day4part1())
12
+ }
13
+
14
+ @Test
15
+ fun day4part2Test () {
16
+ assertEquals(849 , day4part2())
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments