diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day01.java b/2019/src/main/java/be/vandewalleh/aoc/Day01.java index d1b9804..6532d2a 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day01.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day01.java @@ -2,7 +2,6 @@ package be.vandewalleh.aoc; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; import be.vandewalleh.aoc.utils.input.Lines; @Day(1) @@ -16,8 +15,8 @@ public class Day01 { private final int[] input; - public Day01(@Lines Input input) { - this.input = input.getValue(); + public Day01(@Lines int[] input) { + this.input = input; } private int fuel(int mass) { diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day02.java b/2019/src/main/java/be/vandewalleh/aoc/Day02.java index 6127d7e..db5e925 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day02.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day02.java @@ -4,7 +4,6 @@ import be.vandewalleh.aoc.intcode.IntCodeInterpreter; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Csv; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; @Day(2) public class Day02 { @@ -17,8 +16,8 @@ public class Day02 { private final int[] input; - public Day02(@Csv Input input) { - this.input = input.getValue(); + public Day02(@Csv int[] input) { + this.input = input; } private long runInterpreterWith(int noun, int verb) { diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day03.java b/2019/src/main/java/be/vandewalleh/aoc/Day03.java index 5a91c8a..cd90656 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day03.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day03.java @@ -4,7 +4,6 @@ import be.vandewalleh.aoc.geometry.Direction2D; import be.vandewalleh.aoc.geometry.Point2D; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; import be.vandewalleh.aoc.utils.input.Lines; import java.util.ArrayList; @@ -23,9 +22,9 @@ public class Day03 { private final String[] wireA; private final String[] wireB; - public Day03(@Lines Input> input) { - this.wireA = input.getValue().get(0).split(","); - this.wireB = input.getValue().get(1).split(","); + public Day03(@Lines List input) { + this.wireA = input.get(0).split(","); + this.wireB = input.get(1).split(","); } private List path(String[] wire) { diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day04.java b/2019/src/main/java/be/vandewalleh/aoc/Day04.java index b932f46..531d3b9 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day04.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day04.java @@ -2,7 +2,6 @@ package be.vandewalleh.aoc; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; import be.vandewalleh.aoc.utils.input.Text; import java.util.Arrays; @@ -21,8 +20,8 @@ public class Day04 { private final int min; private final int max; - public Day04(@Text Input input) { - var spl = input.getValue().split("-", 2); + public Day04(@Text String input) { + var spl = input.split("-", 2); min = Integer.parseInt(spl[0]); max = Integer.parseInt(spl[1]); } diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day05.java b/2019/src/main/java/be/vandewalleh/aoc/Day05.java index ef40461..6cca80f 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day05.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day05.java @@ -4,7 +4,6 @@ import be.vandewalleh.aoc.intcode.IntCodeInterpreter; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Csv; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; @Day(5) public class Day05 { @@ -17,8 +16,8 @@ public class Day05 { private final int[] input; - public Day05(@Csv Input input) { - this.input = input.getValue(); + public Day05(@Csv int[] input) { + this.input = input; } private Long part1() { diff --git a/2019/src/main/java/be/vandewalleh/aoc/Day06.java b/2019/src/main/java/be/vandewalleh/aoc/Day06.java index 9216450..18887df 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/Day06.java +++ b/2019/src/main/java/be/vandewalleh/aoc/Day06.java @@ -2,7 +2,6 @@ package be.vandewalleh.aoc; import be.vandewalleh.aoc.utils.factory.Days; import be.vandewalleh.aoc.utils.input.Day; -import be.vandewalleh.aoc.utils.input.Input; import be.vandewalleh.aoc.utils.input.Lines; import java.util.*; @@ -18,8 +17,8 @@ public class Day06 { private final List input; - public Day06(@Lines Input> input) { - this.input = input.getValue(); + public Day06(@Lines List input) { + this.input = input; } private final Map reverseOrbits = new HashMap<>(); diff --git a/2019/src/main/java/be/vandewalleh/aoc/intcode/OpCode.java b/2019/src/main/java/be/vandewalleh/aoc/intcode/OpCode.java index 7998e05..fb0bd4a 100644 --- a/2019/src/main/java/be/vandewalleh/aoc/intcode/OpCode.java +++ b/2019/src/main/java/be/vandewalleh/aoc/intcode/OpCode.java @@ -1,7 +1,5 @@ package be.vandewalleh.aoc.intcode; -import java.util.Optional; - public enum OpCode { Add(1, 3), Multiply(2, 3), diff --git a/2020/src/main/kotlin/Day01.kt b/2020/src/main/kotlin/Day01.kt index 7477f67..4db7696 100644 --- a/2020/src/main/kotlin/Day01.kt +++ b/2020/src/main/kotlin/Day01.kt @@ -1,13 +1,10 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(1) -class Day01(@Lines input: Input) { - private val items = input.value - +class Day01(@Lines val items: IntArray) { fun part1(): Int? { items.forEach { a -> items.forEach { b -> diff --git a/2020/src/main/kotlin/Day02.kt b/2020/src/main/kotlin/Day02.kt index 0694478..ffe6637 100644 --- a/2020/src/main/kotlin/Day02.kt +++ b/2020/src/main/kotlin/Day02.kt @@ -1,16 +1,15 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(2) -class Day02(@Lines input: Input>) { +class Day02(@Lines input: List) { private data class PasswordEntry(val range: IntRange, val letter: Char, val password: String) private val regex = "^(\\d+)-(\\d+) ([a-z]): (.*)$".toRegex() - private val passwords = input.value.map { + private val passwords = input.map { val (_, min, max, letter, password) = regex.find(it)!!.groupValues PasswordEntry(min.toInt()..max.toInt(), letter[0], password) } diff --git a/2020/src/main/kotlin/Day03.kt b/2020/src/main/kotlin/Day03.kt index 7433494..b994558 100644 --- a/2020/src/main/kotlin/Day03.kt +++ b/2020/src/main/kotlin/Day03.kt @@ -1,15 +1,14 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(3) -class Day03(@Lines val input: Input>) { +class Day03(@Lines val input: List) { private data class Slope(val x: Int, val y: Int) private fun findSlope(slope: Slope): Int { - val grid = input.value + val grid = input var trees = 0 var x = 0 var y = 0 diff --git a/2020/src/main/kotlin/Day04.kt b/2020/src/main/kotlin/Day04.kt index 7d5e517..c706344 100644 --- a/2020/src/main/kotlin/Day04.kt +++ b/2020/src/main/kotlin/Day04.kt @@ -1,16 +1,15 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Text private typealias Entry = Pair private typealias Entries = List @Day(4) -class Day04(@Text val input: Input) { +class Day04(@Text val input: String) { - val entries = input.value.split("\n\n").map { + val entries = input.split("\n\n").map { it.split(" ", "\n").map { it.split(":").let { (k, v) -> k to v } } } diff --git a/2020/src/main/kotlin/Day05.kt b/2020/src/main/kotlin/Day05.kt index 86be687..4a2fea0 100644 --- a/2020/src/main/kotlin/Day05.kt +++ b/2020/src/main/kotlin/Day05.kt @@ -1,13 +1,12 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(5) -class Day05(@Lines val input: Input>) { +class Day05(@Lines val input: List) { - private val ids = input.value.map { + private val ids = input.map { it.replace("F", "0") .replace("B", "1") .replace("L", "0") diff --git a/2020/src/main/kotlin/Day06.kt b/2020/src/main/kotlin/Day06.kt index b70e0bb..30f22ed 100644 --- a/2020/src/main/kotlin/Day06.kt +++ b/2020/src/main/kotlin/Day06.kt @@ -1,14 +1,13 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Text import org.eclipse.collections.impl.factory.primitive.CharBags @Day(6) -class Day06(@Text val input: Input) { +class Day06(@Text val input: String) { - private val groups = input.value.split("\n\n") + private val groups = input.split("\n\n") fun part1() = groups.sumBy { it.replace("\n", "").toCharArray().toSet().size } diff --git a/2020/src/main/kotlin/Day07.kt b/2020/src/main/kotlin/Day07.kt index da5c78d..9c9a7f6 100644 --- a/2020/src/main/kotlin/Day07.kt +++ b/2020/src/main/kotlin/Day07.kt @@ -1,7 +1,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import org.eclipse.collections.api.factory.Stacks import org.eclipse.collections.api.multimap.list.ImmutableListMultimap @@ -9,7 +8,7 @@ import org.eclipse.collections.api.stack.MutableStack import org.eclipse.collections.impl.factory.Multimaps @Day(7) -class Day07(@Lines val input: Input>) { +class Day07(@Lines val input: List) { private data class Bag(val count: Int, val color: String) @@ -21,7 +20,7 @@ class Day07(@Lines val input: Input>) { val colorRegex = "^(\\w+ \\w+)".toRegex() val requirementRegex = "(\\d+) (\\w+ \\w+) bag".toRegex() - for (line in input.value) { + for (line in input) { val outerColor = colorRegex.find(line)!!.groupValues[1] for (match in requirementRegex.findAll(line)) { val (_, count, color) = match.groupValues diff --git a/2020/src/main/kotlin/Day08.kt b/2020/src/main/kotlin/Day08.kt index fbc15a2..b59174f 100644 --- a/2020/src/main/kotlin/Day08.kt +++ b/2020/src/main/kotlin/Day08.kt @@ -1,15 +1,14 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import org.eclipse.collections.impl.factory.primitive.IntLists import org.eclipse.collections.impl.factory.primitive.IntSets @Day(8) -class Day08(@Lines val input: Input>) { +class Day08(@Lines val input: List) { - private val instructions = input.value.map { + private val instructions = input.map { val words = it.split(" ") Instruction(Operation.valueOf(words[0].capitalize()), words[1].toInt()) }.toTypedArray() diff --git a/2020/src/main/kotlin/Day09.kt b/2020/src/main/kotlin/Day09.kt index 0c8e95c..c85619d 100644 --- a/2020/src/main/kotlin/Day09.kt +++ b/2020/src/main/kotlin/Day09.kt @@ -1,19 +1,16 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(9) -class Day09(@Lines val input: Input) { +class Day09(@Lines val input: LongArray) { private var part1Result = 0L fun part1(): Long? { - val longs = input.value - - for (windowStart in 0 until longs.size - 26) { - val last = longs[windowStart + 25] + for (windowStart in 0 until input.size - 26) { + val last = input[windowStart + 25] if (!isValid(windowStart, last)) { part1Result = last return last @@ -26,8 +23,8 @@ class Day09(@Lines val input: Input) { private fun isValid(windowStart: Int, last: Long): Boolean { for (i in windowStart until windowStart + 25) { for (j in windowStart + 1 until windowStart + 25) { - val f = input.value[i] - val s = input.value[j] + val f = input[i] + val s = input[j] if (f + s == last && f != s) return true } } @@ -37,10 +34,10 @@ class Day09(@Lines val input: Input) { fun part2(): Long { var size = 2 while (true) { - for (startIndex in input.value.indices) { - val lastIndex = input.value.size - 1 - size + for (startIndex in input.indices) { + val lastIndex = input.size - 1 - size if (startIndex + size > lastIndex) break - val slice = input.value.sliceArray(startIndex..startIndex + size) + val slice = input.sliceArray(startIndex..startIndex + size) if (slice.sum() == part1Result) return slice.minOrNull()!! + slice.maxOrNull()!! } size++ diff --git a/2020/src/main/kotlin/Day10.kt b/2020/src/main/kotlin/Day10.kt index d14dfff..9613317 100644 --- a/2020/src/main/kotlin/Day10.kt +++ b/2020/src/main/kotlin/Day10.kt @@ -1,17 +1,16 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import org.eclipse.collections.api.list.primitive.MutableIntList import org.eclipse.collections.impl.factory.primitive.IntLists import org.eclipse.collections.impl.factory.primitive.IntLongMaps @Day(10) -class Day10(@Lines val input: Input) { +class Day10(@Lines val input: IntArray) { fun part1(): Int { - val sorted = IntLists.mutable.of(0, *input.value).apply { + val sorted = IntLists.mutable.of(0, *input).apply { sortThis() add(last + 3) }.toArray().toList() @@ -28,7 +27,7 @@ class Day10(@Lines val input: Input) { } fun part2(): Long { - val sorted: MutableIntList = IntLists.mutable.of(*input.value).apply { sortThis() } + val sorted: MutableIntList = IntLists.mutable.of(*input).apply { sortThis() } val map = IntLongMaps.mutable.empty().apply { put(0, 1L) diff --git a/2020/src/main/kotlin/Day11.kt b/2020/src/main/kotlin/Day11.kt index 667dac8..a50a38b 100644 --- a/2020/src/main/kotlin/Day11.kt +++ b/2020/src/main/kotlin/Day11.kt @@ -1,7 +1,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines private typealias Seats = Array @@ -25,9 +24,9 @@ private fun Seats.asGridString() = joinToString("\n") { it.joinToString("") } private fun Seats.countOccupied() = sumBy { it.count { it == '#' } } @Day(11) -class Day11(@Lines val input: Input>) { +class Day11(@Lines val input: List) { - private val seats: Seats = input.value.map { it.toCharArray() }.toTypedArray() + private val seats: Seats = input.map { it.toCharArray() }.toTypedArray() private val directions = listOf( -1 to -1, diff --git a/2020/src/main/kotlin/Day12.kt b/2020/src/main/kotlin/Day12.kt index b6b3fec..289e9ae 100644 --- a/2020/src/main/kotlin/Day12.kt +++ b/2020/src/main/kotlin/Day12.kt @@ -1,12 +1,11 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import kotlin.math.abs @Day(12) -class Day12(@Lines val input: Input>) { +class Day12(@Lines val input: List) { fun part1(): Int { var x = 0 @@ -15,7 +14,7 @@ class Day12(@Lines val input: Input>) { val dirs = listOf("N", "E", "S", "W") - input.value.forEach { + input.forEach { val dir = it.take(1) val steps = it.drop(1).toInt() @@ -49,7 +48,7 @@ class Day12(@Lines val input: Input>) { var waypointX = 10 var waypointY = -1 - input.value.forEach { + input.forEach { val dir = it.take(1) val steps = it.drop(1).toInt() diff --git a/2020/src/main/kotlin/Day13.kt b/2020/src/main/kotlin/Day13.kt index 0c149d2..d4d54e9 100644 --- a/2020/src/main/kotlin/Day13.kt +++ b/2020/src/main/kotlin/Day13.kt @@ -1,19 +1,18 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import kotlin.math.abs private data class Bus(val index: Int, val id: Long) @Day(13) -class Day13(@Lines val input: Input>) { +class Day13(@Lines val input: List) { fun part1(): Int { - val id = input.value[0].toInt() + val id = input[0].toInt() - val (busId, min) = input.value[1] + val (busId, min) = input[1] .splitToSequence(",") .filterNot { it == "x" } .map { it.toInt() } @@ -28,7 +27,7 @@ class Day13(@Lines val input: Input>) { private fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b fun part2(): Long { - val buses = input.value[1] + val buses = input[1] .splitToSequence(",") .mapIndexedNotNull { index, bus -> if (bus == "x") null diff --git a/2020/src/main/kotlin/Day14.kt b/2020/src/main/kotlin/Day14.kt index 46158ca..b249200 100644 --- a/2020/src/main/kotlin/Day14.kt +++ b/2020/src/main/kotlin/Day14.kt @@ -1,14 +1,13 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import kotlin.math.pow import org.eclipse.collections.impl.factory.primitive.IntObjectMaps import org.eclipse.collections.impl.factory.primitive.LongIntMaps @Day(14) -class Day14(@Lines val input: Input>) { +class Day14(@Lines val input: List) { private val memRe = "mem\\[(\\d+)] = (.*)$".toRegex() @@ -19,7 +18,7 @@ class Day14(@Lines val input: Input>) { var currentMask: String = "" - for (line in input.value) { + for (line in input) { if (line.startsWith("mask")) { currentMask = line.removePrefix("mask = ") } else { @@ -45,7 +44,7 @@ class Day14(@Lines val input: Input>) { var currentMask = "" - for (line in input.value) { + for (line in input) { if (line[1] == 'a') { currentMask = line.substring(7) } else { diff --git a/2020/src/main/kotlin/Day15.kt b/2020/src/main/kotlin/Day15.kt index 71312d3..e64ee3a 100644 --- a/2020/src/main/kotlin/Day15.kt +++ b/2020/src/main/kotlin/Day15.kt @@ -2,15 +2,14 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Csv import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import kotlin.math.abs import org.eclipse.collections.impl.factory.primitive.IntObjectMaps @Day(15) -class Day15(@Csv val input: Input) { +class Day15(@Csv val input: IntArray) { private fun run(until: Int): Int { - val start = input.value + val start = input val map = IntObjectMaps.mutable.empty() diff --git a/2020/src/main/kotlin/Day16.kt b/2020/src/main/kotlin/Day16.kt index afafd32..667c756 100644 --- a/2020/src/main/kotlin/Day16.kt +++ b/2020/src/main/kotlin/Day16.kt @@ -2,7 +2,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day import be.vandewalleh.aoc.utils.input.Groups -import be.vandewalleh.aoc.utils.input.Input import org.eclipse.collections.api.multimap.list.ListMultimap import org.eclipse.collections.api.multimap.list.MutableListMultimap import org.eclipse.collections.api.multimap.set.MutableSetMultimap @@ -10,11 +9,11 @@ import org.eclipse.collections.impl.factory.Multimaps import org.eclipse.collections.impl.multimap.list.FastListMultimap @Day(16) -class Day16(@Groups val input: Input>>) { +class Day16(@Groups val input: List>) { - private val rangesGroup = input.value[0] - private val myTicket = input.value[1][1] - private val nearbyTicketsGroup = input.value[2].drop(1) + private val rangesGroup = input[0] + private val myTicket = input[1][1] + private val nearbyTicketsGroup = input[2].drop(1) private val rangeRe = "(\\d+)-(\\d+)".toRegex() diff --git a/2020/src/main/kotlin/Day17.kt b/2020/src/main/kotlin/Day17.kt index 1938751..3aa981e 100644 --- a/2020/src/main/kotlin/Day17.kt +++ b/2020/src/main/kotlin/Day17.kt @@ -1,7 +1,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines private data class Point(val x: Int, val y: Int, val z: Int) @@ -10,7 +9,7 @@ private data class Point4(val x: Int, val y: Int, val z: Int, val blah: Int) private enum class State { Active, Inactive } @Day(17) -class Day17(@Lines val input: Input>) { +class Day17(@Lines val input: List) { fun part1(): Int { val grid = parseGrid { x, y -> Point(x, y, 0) } @@ -26,7 +25,7 @@ class Day17(@Lines val input: Input>) { private fun parseGrid(pointFactory: (x: Int, y: Int) -> T): MutableMap { val grid = mutableMapOf() - input.value.forEachIndexed { index, row -> + input.forEachIndexed { index, row -> row.forEachIndexed { col, char -> val state = if (char == '#') State.Active else State.Inactive grid[pointFactory(index, col)] = state diff --git a/2020/src/main/kotlin/Day18.kt b/2020/src/main/kotlin/Day18.kt index cf7ed71..8128d8e 100644 --- a/2020/src/main/kotlin/Day18.kt +++ b/2020/src/main/kotlin/Day18.kt @@ -1,7 +1,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import java.util.* import org.slf4j.Logger @@ -19,10 +18,10 @@ private inline fun Logger.debug(msg: () -> Any) { } @Day(18) -class Day18(@Lines val input: Input>) { +class Day18(@Lines val input: List) { private val logger = LoggerFactory.getLogger("Day18") - private val lines = input.value.map { it.replace(" ", "") } + private val lines = input.map { it.replace(" ", "") } private fun parseGroups(line: String): Map> { var depth = 0 diff --git a/2020/src/main/kotlin/Day19.kt b/2020/src/main/kotlin/Day19.kt index 457392f..8632c8c 100644 --- a/2020/src/main/kotlin/Day19.kt +++ b/2020/src/main/kotlin/Day19.kt @@ -2,14 +2,12 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day import be.vandewalleh.aoc.utils.input.Groups -import be.vandewalleh.aoc.utils.input.Input import java.util.* -import kotlin.collections.ArrayList @Day(19) -class Day19(@Groups val input: Input>>) { - private val rules = input.value[0] - private val messages = input.value[1] +class Day19(@Groups val input: List>) { + private val rules = input[0] + private val messages = input[1] sealed class Rule { data class CharRule(val value: Char) : Rule() diff --git a/2020/src/main/kotlin/Day20.kt b/2020/src/main/kotlin/Day20.kt index ad7d725..77cf3a9 100644 --- a/2020/src/main/kotlin/Day20.kt +++ b/2020/src/main/kotlin/Day20.kt @@ -5,16 +5,13 @@ import be.vandewalleh.aoc.days.geometry.gridOf import be.vandewalleh.aoc.days.geometry.transformations import be.vandewalleh.aoc.utils.input.Day import be.vandewalleh.aoc.utils.input.Groups -import be.vandewalleh.aoc.utils.input.Input -import java.util.* -import kotlin.collections.ArrayList import kotlin.math.sqrt private typealias Tile = Grid @Day(20) -class Day20(@Groups val input: Input>>) { - private val tiles: Map = input.value +class Day20(@Groups val input: List>) { + private val tiles: Map = input .map { it[0].let { it.substring(5 until it.indexOf(':')).toInt() } to it.drop(1) } .associate { (id, tile) -> id to gridOf(tile) } diff --git a/2020/src/main/kotlin/Day21.kt b/2020/src/main/kotlin/Day21.kt index 529936a..44ecdec 100644 --- a/2020/src/main/kotlin/Day21.kt +++ b/2020/src/main/kotlin/Day21.kt @@ -1,15 +1,14 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import org.eclipse.collections.api.factory.Bags import org.eclipse.collections.api.multimap.set.MutableSetMultimap import org.eclipse.collections.impl.factory.Multimaps @Day(21) -class Day21(@Lines val input: Input>) { - private val foods = input.value.map { line -> +class Day21(@Lines val input: List) { + private val foods = input.map { line -> val parOpen = line.indexOf('(') val ingredients = line.substring(0 until parOpen - 1).split(" ") val allergens = line.substring(parOpen + 1 until line.length - 1).removePrefix("contains ").split(", ") diff --git a/2020/src/main/kotlin/Day22.kt b/2020/src/main/kotlin/Day22.kt index de50f4d..7ac3857 100644 --- a/2020/src/main/kotlin/Day22.kt +++ b/2020/src/main/kotlin/Day22.kt @@ -2,14 +2,13 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day import be.vandewalleh.aoc.utils.input.Groups -import be.vandewalleh.aoc.utils.input.Input private data class PlayedGame(val a: List, val b: List) @Day(22) -class Day22(@Groups val input: Input>>) { - private val one = input.value[0].drop(1).map { it.toInt() } - private val two = input.value[1].drop(1).map { it.toInt() } +class Day22(@Groups val input: List>) { + private val one = input[0].drop(1).map { it.toInt() } + private val two = input[1].drop(1).map { it.toInt() } fun part1(): Long { val oneDeque = ArrayDeque(one) diff --git a/2020/src/main/kotlin/Day23.kt b/2020/src/main/kotlin/Day23.kt index 5d56fab..e0d32d2 100644 --- a/2020/src/main/kotlin/Day23.kt +++ b/2020/src/main/kotlin/Day23.kt @@ -1,12 +1,11 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Text @Day(23) -class Day23(@Text val input: Input) { - private val cups = input.value.toCharArray().map { it.toString().toInt() } +class Day23(@Text val input: String) { + private val cups = input.toCharArray().map { it.toString().toInt() } private fun ringSequence(head: Ring.Node) = generateSequence(head) { it.next } diff --git a/2020/src/main/kotlin/Day24.kt b/2020/src/main/kotlin/Day24.kt index 0c417ec..f5de271 100644 --- a/2020/src/main/kotlin/Day24.kt +++ b/2020/src/main/kotlin/Day24.kt @@ -1,14 +1,13 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines import org.eclipse.collections.api.bag.Bag import org.eclipse.collections.api.bag.MutableBag import org.eclipse.collections.api.factory.Bags @Day(24) -class Day24(@Lines val input: Input>) { +class Day24(@Lines val input: List) { private data class HexPoint(val x: Int, val y: Int, val z: Int) { fun translate(other: HexPoint) = HexPoint(this.x + other.x, this.y + other.y, this.z + other.z) @@ -31,7 +30,7 @@ class Day24(@Lines val input: Input>) { .map { Direction.valueOf(it.toUpperCase()) } .toList() - private val tiles = input.value.map { parseTile(it) }.map { + private val tiles = input.map { parseTile(it) }.map { it.map { it.coordinates }.reduce { acc, ints -> acc.translate(ints) } } diff --git a/2020/src/main/kotlin/Day25.kt b/2020/src/main/kotlin/Day25.kt index 37b7a53..a3d511c 100644 --- a/2020/src/main/kotlin/Day25.kt +++ b/2020/src/main/kotlin/Day25.kt @@ -1,13 +1,12 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(25) -class Day25(@Lines val input: Input) { - private val doorPublicKey = input.value[0] - private val cardPublicKey = input.value[1] +class Day25(@Lines val input: IntArray) { + private val doorPublicKey = input[0] + private val cardPublicKey = input[1] private fun encryptionKey(loopSize: Int, publicKey: Int) = transformSubjectNumber(loopSize, publicKey) diff --git a/2020/src/main/kotlin/Main.kt b/2020/src/main/kotlin/Main.kt index 66f7661..859d17e 100644 --- a/2020/src/main/kotlin/Main.kt +++ b/2020/src/main/kotlin/Main.kt @@ -2,6 +2,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.factory.createDay -fun main() = with(createDay()) { +fun main() = with(createDay()) { println(part1()) } diff --git a/2020/src/main/kotlin/geometry/GridTranformations.kt b/2020/src/main/kotlin/geometry/GridTranformations.kt index 8dccba5..caddef2 100644 --- a/2020/src/main/kotlin/geometry/GridTranformations.kt +++ b/2020/src/main/kotlin/geometry/GridTranformations.kt @@ -1,7 +1,5 @@ package be.vandewalleh.aoc.days.geometry -import java.util.* - private fun ArrayList.reversed(): ArrayList { val out = ArrayList(this.size) asReversed().forEach { out.add(it) } diff --git a/2020/src/test/kotlin/Day01Test.kt b/2020/src/test/kotlin/Day01Test.kt index c8848d8..6d71509 100644 --- a/2020/src/test/kotlin/Day01Test.kt +++ b/2020/src/test/kotlin/Day01Test.kt @@ -1,13 +1,12 @@ package be.vandewalleh.aoc.days -import io.micronaut.context.BeanContext -import io.micronaut.context.getBean +import be.vandewalleh.aoc.utils.factory.createDay import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class Day01Test { - private val day = BeanContext.run().getBean() + private val day = createDay() @Test fun `part1 result`() { diff --git a/2020/src/test/kotlin/Day03Test.kt b/2020/src/test/kotlin/Day03Test.kt index e812f9f..6331422 100644 --- a/2020/src/test/kotlin/Day03Test.kt +++ b/2020/src/test/kotlin/Day03Test.kt @@ -1,8 +1,8 @@ package be.vandewalleh.aoc.days -import be.vandewalleh.aoc.utils.input.Input -import be.vandewalleh.aoc.utils.input.createDay +import be.vandewalleh.aoc.utils.factory.createDay import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test @@ -22,7 +22,7 @@ class Day03Test { "#.##...#...", "#...##....#", ".#..#...#.#", - ).let { Input(it) } + ) private val day03 = Day03(example) @@ -43,11 +43,13 @@ class Day03Test { private val day03 = createDay() @Test + @Disabled fun `part1 result`() { assertThat(day03.part1()).isEqualTo(294) } @Test + @Disabled fun `part2 result`() { assertThat(day03.part2()).isEqualTo(5774564250) } diff --git a/2020/src/test/kotlin/Day04Test.kt b/2020/src/test/kotlin/Day04Test.kt index 8d59f07..75d19dc 100644 --- a/2020/src/test/kotlin/Day04Test.kt +++ b/2020/src/test/kotlin/Day04Test.kt @@ -1,7 +1,6 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.factory.createDay -import be.vandewalleh.aoc.utils.input.Input import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Nested @@ -26,7 +25,6 @@ class Day04Test { hcl:#cfa07d eyr:2025 pid:166559648 iyr:2011 ecl:brn hgt:59in """.trimIndent() - .let { Input(it) } private val day04 = Day04(example) @@ -63,7 +61,7 @@ class Day04Test { hgt:59cm ecl:zzz eyr:2038 hcl:74454a iyr:2023 pid:3556412378 byr:2007 - """.trimIndent().let { Input(it) } + """.trimIndent() assertThat(Day04(input).part2()).isEqualTo(0) } @@ -83,7 +81,7 @@ class Day04Test { eyr:2022 iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719 - """.trimIndent().let { Input(it) } + """.trimIndent() assertThat(Day04(input).part2()).isEqualTo(4) } diff --git a/2020/src/test/kotlin/Day13Test.kt b/2020/src/test/kotlin/Day13Test.kt index 3b19981..e8c90cb 100644 --- a/2020/src/test/kotlin/Day13Test.kt +++ b/2020/src/test/kotlin/Day13Test.kt @@ -1,6 +1,5 @@ package be.vandewalleh.aoc.days -import be.vandewalleh.aoc.utils.input.Input import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.CsvSource @@ -20,7 +19,7 @@ class Day13Test { ) @ParameterizedTest fun examples(buses: String, answer: Long) { - val input = Input(listOf("", buses)) + val input = listOf("", buses) assertThat(Day13(input).part2()).isEqualTo(answer) } diff --git a/2020/src/test/kotlin/Day18Test.kt b/2020/src/test/kotlin/Day18Test.kt index e98dc05..a236003 100644 --- a/2020/src/test/kotlin/Day18Test.kt +++ b/2020/src/test/kotlin/Day18Test.kt @@ -1,6 +1,5 @@ package be.vandewalleh.aoc.days -import be.vandewalleh.aoc.utils.input.Input import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.CsvSource @@ -17,7 +16,7 @@ class Day18Test { ]) @ParameterizedTest fun examplesPart2(input: String, output: Long) { - val day18 = Day18(Input(listOf(input))) + val day18 = Day18(listOf(input)) assertThat(day18.part2()).isEqualTo(output) } } diff --git a/2021/src/main/kotlin/Day01.kt b/2021/src/main/kotlin/Day01.kt index d6e6dd1..05caed8 100644 --- a/2021/src/main/kotlin/Day01.kt +++ b/2021/src/main/kotlin/Day01.kt @@ -1,12 +1,10 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.input.Day -import be.vandewalleh.aoc.utils.input.Input import be.vandewalleh.aoc.utils.input.Lines @Day(1) -class Day01(@Lines input: Input) { - private val items = input.value +class Day01(@Lines val items: IntArray) { fun part1(): Int { var count = 0 diff --git a/2021/src/main/kotlin/Main.kt b/2021/src/main/kotlin/Main.kt index d96ef5a..f7c0440 100644 --- a/2021/src/main/kotlin/Main.kt +++ b/2021/src/main/kotlin/Main.kt @@ -2,6 +2,8 @@ package be.vandewalleh.aoc.days import be.vandewalleh.aoc.utils.factory.createDay -fun main() = with(createDay()) { - println(part2()) +fun main() { + with(createDay()) { + println(part2()) + } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5ad0bcc..3093307 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,6 +12,6 @@ repositories { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0") implementation("com.konghq:unirest-java:3.11.04") } diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 78bac7c..da51438 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -17,10 +17,10 @@ object Libs { } object Micronaut { - private const val version = "2.2.0" + private const val version = "3.2.0" const val inject = "io.micronaut:micronaut-inject:$version" const val core = "io.micronaut:micronaut-core:$version" - const val kotlin = "io.micronaut.kotlin:micronaut-kotlin-extension-functions:$version" + const val kotlin = "io.micronaut.kotlin:micronaut-kotlin-extension-functions:3.0.0" const val processor = "io.micronaut:micronaut-inject-java:$version" } diff --git a/buildSrc/src/main/kotlin/java-convention.gradle.kts b/buildSrc/src/main/kotlin/java-convention.gradle.kts index 8be33e9..eb68d79 100644 --- a/buildSrc/src/main/kotlin/java-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/java-convention.gradle.kts @@ -14,11 +14,10 @@ group = "be.vandewalleh" version = "1.0-SNAPSHOT" java { - sourceCompatibility = JavaVersion.VERSION_15 - targetCompatibility = JavaVersion.VERSION_15 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } tasks.withType { options.encoding = "UTF-8" - options.compilerArgs.add("--enable-preview") } diff --git a/buildSrc/src/main/kotlin/kotlin-convention.gradle.kts b/buildSrc/src/main/kotlin/kotlin-convention.gradle.kts index 6af74db..97457b8 100644 --- a/buildSrc/src/main/kotlin/kotlin-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-convention.gradle.kts @@ -7,12 +7,12 @@ plugins { dependencies { implementation(kotlin("stdlib-jdk8")) - implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.4.20")) + implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.6.0")) } tasks.withType { kotlinOptions { - jvmTarget = "15" + jvmTarget = "17" javaParameters = true freeCompilerArgs = listOf( "-Xinline-classes", diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 089b9f3..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-rc-1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 5c9675e..d1487f4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,4 @@ rootProject.name = "Advent of Code" include("utils") -include("2019") include("2020") include("2021") diff --git a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Annotations.kt b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Annotations.kt index 4148d10..5b75f0c 100644 --- a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Annotations.kt +++ b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Annotations.kt @@ -4,26 +4,42 @@ package be.vandewalleh.aoc.utils.input import io.micronaut.context.annotation.Prototype import io.micronaut.core.annotation.Introspected -import javax.inject.Qualifier +import jakarta.inject.Qualifier +import java.lang.annotation.Inherited @Prototype @Qualifier @Introspected @Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) annotation class Day(val value: Int) @Qualifier @Prototype +@Inherited +@Retention(AnnotationRetention.RUNTIME) annotation class DayInput -@DayInput +@Qualifier +@Prototype +@Inherited +@Retention(AnnotationRetention.RUNTIME) annotation class Csv -@DayInput +@Qualifier +@Prototype +@Inherited +@Retention(AnnotationRetention.RUNTIME) annotation class Text -@DayInput +@Qualifier +@Prototype +@Inherited +@Retention(AnnotationRetention.RUNTIME) annotation class Lines -@DayInput +@Qualifier +@Prototype +@Inherited +@Retention(AnnotationRetention.RUNTIME) annotation class Groups diff --git a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Input.kt b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Input.kt deleted file mode 100644 index 52c5933..0000000 --- a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/Input.kt +++ /dev/null @@ -1,7 +0,0 @@ -package be.vandewalleh.aoc.utils.input - -/** - * Wrapper class so that micronaut is not confused with an other injectable - * container type when using an iterable / array - */ -data class Input(val value: T) diff --git a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/InputFactory.kt b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/InputFactory.kt index d686d36..7901ffa 100644 --- a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/InputFactory.kt +++ b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/InputFactory.kt @@ -6,75 +6,39 @@ import kotlin.io.path.ExperimentalPathApi import kotlin.io.path.readLines import kotlin.io.path.readText -/** - * Load challenge inputs and convert them to the appropriate format - * - * contains horrible hacks while waiting for generic support in bean injection - * @see [micronaut-2775](https://github.com/micronaut-projects/micronaut-core/issues/2775) - */ @Factory @ExperimentalPathApi class InputFactory(private val resourceLoader: ResourceLoader) { @Csv - fun csv(injectionPoint: InjectionPoint<*>): Input<*> = - when (val param = injectionPoint.typeNameOfAnnotation()) { - INT_ARRAY -> injectionPoint - .read() - .split(",") - .map { it.toInt() } - .toIntArray() - .wrap() - LONG_ARRAY -> injectionPoint - .read() - .split(",") - .map { it.toLong() } - .toLongArray() - .wrap() - else -> error("Unsupported type $param") - } + fun csvInts(injectionPoint: InjectionPoint<*>): IntArray = + injectionPoint.csv().map { it.toInt() }.toIntArray() + + @Csv + fun csvLongs(injectionPoint: InjectionPoint<*>): LongArray = + injectionPoint.csv().map { it.toLong() }.toLongArray() + + private fun InjectionPoint<*>.csv() = read().split(",") @Lines - fun lines(injectionPoint: InjectionPoint<*>): Input<*> = - when (val param = injectionPoint.typeNameOfAnnotation()) { - INT_ARRAY -> injectionPoint - .lines() - .map { it.toInt() } - .toList() - .toIntArray() - .wrap() - LONG_ARRAY -> injectionPoint - .lines() - .map { it.toLong() } - .toList() - .toLongArray() - .wrap() - STRING_LIST -> injectionPoint - .lines() - .toList() - .wrap() - else -> error("Unsupported type $param") - } + fun linesInts(injectionPoint: InjectionPoint<*>): IntArray = + injectionPoint.lines().map { it.toInt() }.toList().toIntArray() + + @Lines + fun linesLongs(injectionPoint: InjectionPoint<*>): LongArray = + injectionPoint.lines().map { it.toLong() }.toList().toLongArray() + + @Lines + fun lines(injectionPoint: InjectionPoint<*>): List = + injectionPoint.lines().toList() @Text - fun text(injectionPoint: InjectionPoint<*>): Input = - injectionPoint.read().wrap() + fun text(injectionPoint: InjectionPoint<*>): String = + injectionPoint.read() @Groups - fun groups(injectionPoint: InjectionPoint<*>): Input>> = - injectionPoint.read().split("\n\n").map { it.lines() }.wrap() - - - private fun T.wrap() = Input(this) - - private inline fun InjectionPoint<*>.typeNameOfAnnotation() = declaringBean - .constructor - .arguments - .find { it.hasAnnotation() } - ?.typeName - ?.removePrefix("be.vandewalleh.aoc.utils.input.Input<") - ?.removeSuffix(">") - ?: error("??") + fun groups(injectionPoint: InjectionPoint<*>): List> = + injectionPoint.read().split("\n\n").map { it.lines() } private fun InjectionPoint<*>.path() = resourceLoader.ofDay(getDay(this)) private fun InjectionPoint<*>.read() = path().readText().trim() @@ -93,10 +57,4 @@ class InputFactory(private val resourceLoader: ResourceLoader) { return dayAnnotation.get().intValue("value").asInt } - companion object { - private const val INT_ARRAY = "int[]" - private const val LONG_ARRAY = "long[]" - private const val STRING_LIST = "java.util.List" - } - } diff --git a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/MicronautExtensions.kt b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/MicronautExtensions.kt index fb73e8d..d9f8124 100644 --- a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/MicronautExtensions.kt +++ b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/MicronautExtensions.kt @@ -6,6 +6,3 @@ import java.util.* internal inline fun AnnotationMetadataProvider.findAnnotation(): Optional> = findAnnotation(T::class.java) - -internal inline fun AnnotationMetadataProvider.hasAnnotation(): Boolean = - findAnnotation(T::class.java).isPresent diff --git a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/ResourceLoader.kt b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/ResourceLoader.kt index 9ebd69b..f058b0a 100644 --- a/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/ResourceLoader.kt +++ b/utils/src/main/kotlin/be/vandewalleh/aoc/utils/input/ResourceLoader.kt @@ -1,8 +1,8 @@ package be.vandewalleh.aoc.utils.input +import jakarta.inject.Singleton import java.io.File import java.nio.file.Path -import javax.inject.Singleton interface ResourceLoader { fun ofDay(day: Int): Path diff --git a/utils/src/test/kotlin/input/DayTest.kt b/utils/src/test/kotlin/input/DayTest.kt index 64a36e3..31f755d 100644 --- a/utils/src/test/kotlin/input/DayTest.kt +++ b/utils/src/test/kotlin/input/DayTest.kt @@ -3,7 +3,7 @@ package be.vandewalleh.aoc.utils.input import be.vandewalleh.aoc.utils.factory.createDay import com.google.common.jimfs.Jimfs import io.micronaut.context.annotation.Replaces -import javax.inject.Singleton +import jakarta.inject.Singleton import kotlin.io.path.ExperimentalPathApi import kotlin.io.path.writeText import org.assertj.core.api.Assertions.assertThat @@ -43,39 +43,39 @@ class DayTest { } @Day(1) - class TextStringExample(@Text val input: Input) + class TextStringExample(@Text val input: String) @Day(2) - class CsvIntArrayExample(@Csv val input: Input) + class CsvIntArrayExample(@Csv val input: IntArray) @Day(3) - class IntLinesExample(@Lines val input: Input) + class IntLinesExample(@Lines val input: IntArray) @Day(4) - class StringLinesExample(@Lines val input: Input>) + class StringLinesExample(@Lines val input: List) @Test fun `check @Text String`() { val day = createDay() - assertThat(day.input.value).isEqualTo("blablabla") + assertThat(day.input).isEqualTo("blablabla") } @Test fun `check @Csv IntArray`() { val day = createDay() - assertThat(day.input.value).containsExactly(1, +2, 3, 4, -5) + assertThat(day.input).containsExactly(1, +2, 3, 4, -5) } @Test fun `check @Lines IntArray`() { val day = createDay() - assertThat(day.input.value).containsExactly(1779, 1737, 1537, 1167, 1804, 1873) + assertThat(day.input).containsExactly(1779, 1737, 1537, 1167, 1804, 1873) } @Test fun `check @Lines strings`() { val day = createDay() - assertThat(day.input.value).containsExactly("a", "bb", "ccc") + assertThat(day.input).containsExactly("a", "bb", "ccc") } }