Compare commits
1 Commits
master
..
fc4946b613
| Author | SHA1 | Date | |
|---|---|---|---|
| fc4946b613 |
+14
-3
@@ -1,7 +1,18 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("aoc")
|
id("kotlin-convention")
|
||||||
|
kotlin("kapt")
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
dependencies {
|
||||||
mainClass.set("be.vandewalleh.aoc.days.MainKt")
|
implementation(project(":utils"))
|
||||||
|
|
||||||
|
kapt(Libs.Micronaut.processor)
|
||||||
|
|
||||||
|
implementation(Libs.Slf4J.api)
|
||||||
|
runtimeOnly(Libs.Slf4J.simple)
|
||||||
|
|
||||||
|
implementation(Libs.eclipseCollections)
|
||||||
|
|
||||||
|
testImplementation(Libs.Jmh.core)
|
||||||
|
kaptTest(Libs.Jmh.processor)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
target area: x=20..30, y=-10..-5
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
target area: x=139..187, y=-148..-89
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import nre, strutils
|
|
||||||
|
|
||||||
let
|
|
||||||
regex = re"x=(-?\d+)..(-?\d+), y=(-?\d+)..(-?\d+)"
|
|
||||||
data = readFile("input.txt")
|
|
||||||
captures = data.find(regex).get.captures
|
|
||||||
x1 = captures[0].parseInt()
|
|
||||||
x2 = captures[1].parseInt()
|
|
||||||
y1 = captures[2].parseInt()
|
|
||||||
y2 = captures[3].parseInt()
|
|
||||||
minX = min(x1, x2)
|
|
||||||
maxX = max(x1, x2)
|
|
||||||
minY = min(y1, y2)
|
|
||||||
maxY = max(y1, y2)
|
|
||||||
|
|
||||||
proc land(dx: int, dy: int): int =
|
|
||||||
var dx = dx
|
|
||||||
var dy = dy
|
|
||||||
var x = 0
|
|
||||||
var y = 0
|
|
||||||
var high = y
|
|
||||||
while x < maxX and y > minY:
|
|
||||||
x += dx
|
|
||||||
y += dy
|
|
||||||
if dx > 0: dx -= 1
|
|
||||||
elif dx < 0: dx += 1
|
|
||||||
dy -= 1
|
|
||||||
high = max(high, y)
|
|
||||||
if x in minX..maxX and y in minY..maxY:
|
|
||||||
return high
|
|
||||||
return -1
|
|
||||||
|
|
||||||
var high = 0
|
|
||||||
var match = 0
|
|
||||||
for x in -1000..1000:
|
|
||||||
for y in -1000..1000:
|
|
||||||
let res = land(x, y)
|
|
||||||
if res != -1: match += 1
|
|
||||||
high = max(res, high)
|
|
||||||
|
|
||||||
echo(high)
|
|
||||||
echo(match)
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
class Counter<K> : Iterable<Map.Entry<K, Long>> {
|
|
||||||
private val map = HashMap<K, Long>()
|
|
||||||
operator fun get(key: K) = map[key] ?: 0L
|
|
||||||
|
|
||||||
operator fun set(key: K, count: Long) {
|
|
||||||
map[key] = count
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun set(key: K, count: Int) {
|
|
||||||
if (count == 0)
|
|
||||||
map.remove(key)
|
|
||||||
else
|
|
||||||
map[key] = count.toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun toMap() = map.toMap(HashMap())
|
|
||||||
override fun toString() = map.toString()
|
|
||||||
|
|
||||||
fun minValue() = map.minOf { it.value }
|
|
||||||
fun maxValue() = map.maxOf { it.value }
|
|
||||||
|
|
||||||
override fun iterator() = toMap().iterator()
|
|
||||||
|
|
||||||
companion object
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun <T> Counter.Companion.invoke(items: Iterable<T>) = Counter<T>().apply { items.forEach { this[it] += 1 } }
|
|
||||||
@@ -50,7 +50,7 @@ class Day10 : BaseDay() {
|
|||||||
stack.add(char)
|
stack.add(char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack.foldRight(0L) { char, score -> score * 5 + points[char]!! }
|
stack.asReversed().fold(0L) { score, char -> score * 5 + points[char]!! }
|
||||||
}.sorted().let { it[it.size / 2] }
|
}.sorted().let { it[it.size / 2] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
import be.vandewalleh.aoc.utils.BaseDay
|
|
||||||
import be.vandewalleh.aoc.utils.input.Day
|
|
||||||
|
|
||||||
@Day
|
|
||||||
class Day11 : BaseDay() {
|
|
||||||
|
|
||||||
private data class Point(val x: Int, val y: Int) {
|
|
||||||
fun adjacents() = listOf(
|
|
||||||
copy(y = y - 1),
|
|
||||||
copy(x = x + 1),
|
|
||||||
copy(y = y + 1),
|
|
||||||
copy(x = x - 1),
|
|
||||||
copy(y = y - 1, x = x - 1),
|
|
||||||
copy(x = x + 1, y = y + 1),
|
|
||||||
copy(y = y + 1, x = x - 1),
|
|
||||||
copy(x = x + 1, y = y - 1),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val map by lazy {
|
|
||||||
input.lines.value.flatMapIndexed { y, line ->
|
|
||||||
line.mapIndexed { x, value -> Point(x, y) to value.digitToInt() }
|
|
||||||
}.toMap()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part1(): Int {
|
|
||||||
val map = map.toMap(HashMap())
|
|
||||||
var count = 0
|
|
||||||
repeat(100) { count += step(map) }
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun step(map: HashMap<Point, Int>): Int {
|
|
||||||
map.keys.forEach { map[it] = map[it]!! + 1 }
|
|
||||||
val flashed = hashSetOf<Point>()
|
|
||||||
while (true) {
|
|
||||||
val count = map.entries.asSequence()
|
|
||||||
.filter { it.value > 9 }
|
|
||||||
.filter { it.key !in flashed }
|
|
||||||
.onEach { flashed += it.key }
|
|
||||||
.flatMap { it.key.adjacents() }
|
|
||||||
.filter { it in map }
|
|
||||||
.onEach { map[it] = map[it]!! + 1 }
|
|
||||||
.count()
|
|
||||||
|
|
||||||
if (count == 0) break
|
|
||||||
}
|
|
||||||
|
|
||||||
map.entries.filter { it.value > 9 }
|
|
||||||
.map { it.key }
|
|
||||||
.forEach { map[it] = 0 }
|
|
||||||
|
|
||||||
return flashed.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part2(): Int {
|
|
||||||
val map = map.toMap(HashMap())
|
|
||||||
repeat(10000) { if (step(map) == map.size) return it + 1 }
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
import be.vandewalleh.aoc.utils.BaseDay
|
|
||||||
import be.vandewalleh.aoc.utils.input.Day
|
|
||||||
|
|
||||||
@Day
|
|
||||||
class Day12 : BaseDay() {
|
|
||||||
|
|
||||||
private val map by lazy {
|
|
||||||
HashMap<String, MutableSet<String>>().also { map ->
|
|
||||||
input.lines.value.map { it.split("-") }
|
|
||||||
.flatMap { (a, b) -> listOf(listOf(a, b), listOf(b, a)) }
|
|
||||||
.filter { (_, b) -> b != "start" }
|
|
||||||
.forEach { (a, b) -> map.computeIfAbsent(a) { HashSet() }.add(b) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part1(): Any {
|
|
||||||
val stack = map["start"]!!.map { listOf("start", it) }.toMutableList()
|
|
||||||
|
|
||||||
var i = 0
|
|
||||||
while (stack.isNotEmpty()) {
|
|
||||||
val path = stack.removeLast()
|
|
||||||
val node = path.last()
|
|
||||||
for (next in map[node]!!) {
|
|
||||||
when {
|
|
||||||
next == "end" -> i++
|
|
||||||
next[0].isUpperCase() -> stack.add(path + next)
|
|
||||||
else -> if (next !in path) stack.add(path + next)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part2(): Any {
|
|
||||||
val stack = map["start"]!!.map { listOf("start", it) }.toMutableList()
|
|
||||||
|
|
||||||
var i = 0
|
|
||||||
while (stack.isNotEmpty()) {
|
|
||||||
val path = stack.removeLast()
|
|
||||||
val node = path.last()
|
|
||||||
for (next in map[node]!!) {
|
|
||||||
when {
|
|
||||||
next == "end" -> i++
|
|
||||||
next[0].isUpperCase() -> stack.add(path + next)
|
|
||||||
else -> {
|
|
||||||
val hasTwoSmallCaves = path.filter { it[0].isLowerCase() }
|
|
||||||
.any { cur -> path.count { it == cur } == 2 }
|
|
||||||
if (!hasTwoSmallCaves || next !in path) stack.add(path + next)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
import be.vandewalleh.aoc.utils.BaseDay
|
|
||||||
import be.vandewalleh.aoc.utils.input.Day
|
|
||||||
|
|
||||||
@Day
|
|
||||||
class Day13 : BaseDay() {
|
|
||||||
private data class Point(val x: Int, val y: Int)
|
|
||||||
|
|
||||||
override fun part1(): Int {
|
|
||||||
val (nums, folds) = input()
|
|
||||||
val (axis, value) = folds.first()
|
|
||||||
return nums.toSet().fold(axis, value.toInt()).size
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Set<Point>.fold(axis: String, value: Int) = if (axis == "x") {
|
|
||||||
val (left, right) = partition { it.x < value }
|
|
||||||
left.toSet() + right.map { it.copy(x = 2 * value - it.x) }
|
|
||||||
} else {
|
|
||||||
val (top, bottom) = partition { it.y < value }
|
|
||||||
top.toSet() + bottom.map { it.copy(y = 2 * value - it.y) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part2(): String {
|
|
||||||
val (nums, folds) = input()
|
|
||||||
val all = folds.fold(nums.toSet()) { all, (axis, value) -> all.fold(axis, value.toInt()) }
|
|
||||||
val res = StringBuilder()
|
|
||||||
for (y in 0..all.maxOf { it.y }) {
|
|
||||||
for (x in 0..all.maxOf { it.x }) {
|
|
||||||
if (Point(x, y) in all) res.append('#') else res.append(" ")
|
|
||||||
}
|
|
||||||
res.appendLine()
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun input(): Pair<List<Point>, List<List<String>>> {
|
|
||||||
val gr = input.text.split("\n\n")
|
|
||||||
val nums = gr[0].lines().map { it.split(",") }.map { (x, y) -> Point(x.toInt(), y.toInt()) }
|
|
||||||
val folds = "([xy])=(\\d+)".toRegex().findAll(gr[1]).map { it.groupValues.drop(1) }.toList()
|
|
||||||
return nums to folds
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
import be.vandewalleh.aoc.utils.BaseDay
|
|
||||||
import be.vandewalleh.aoc.utils.input.Day
|
|
||||||
|
|
||||||
@Day
|
|
||||||
class Day14 : BaseDay() {
|
|
||||||
|
|
||||||
private fun run(step: Int): Long {
|
|
||||||
val template = input.lines.value.first()
|
|
||||||
val pairs = input.findAll("(\\S+) -> (\\S)").associate { it[0] to it[1] }
|
|
||||||
val polymer = Counter(template.windowed(2)) // {NN=1, NC=1, CB=1}
|
|
||||||
val counts = Counter(template.toCharArray().toList()) // {N=2, C=1, ...}
|
|
||||||
|
|
||||||
repeat(step) {
|
|
||||||
polymer.forEach { (pair, value) ->
|
|
||||||
val (left, right) = pairs[pair]!!.let { m -> pair[0] + m to m + pair[1] }
|
|
||||||
polymer[pair] -= value
|
|
||||||
polymer[left] += value
|
|
||||||
polymer[right] += value
|
|
||||||
counts[left[1]] += value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return counts.maxValue() - counts.minValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun part1() = run(10)
|
|
||||||
override fun part2() = run(40)
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
7222221271
|
|
||||||
6463754232
|
|
||||||
3373484684
|
|
||||||
4674461265
|
|
||||||
1187834788
|
|
||||||
1175316351
|
|
||||||
8211411846
|
|
||||||
4657828333
|
|
||||||
5286325337
|
|
||||||
5771324832
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
pn-TY
|
|
||||||
rp-ka
|
|
||||||
az-aw
|
|
||||||
al-IV
|
|
||||||
pn-co
|
|
||||||
end-rp
|
|
||||||
aw-TY
|
|
||||||
rp-pn
|
|
||||||
al-rp
|
|
||||||
end-al
|
|
||||||
IV-co
|
|
||||||
end-TM
|
|
||||||
co-TY
|
|
||||||
TY-ka
|
|
||||||
aw-pn
|
|
||||||
aw-IV
|
|
||||||
pn-IV
|
|
||||||
IV-ka
|
|
||||||
TM-rp
|
|
||||||
aw-PD
|
|
||||||
start-IV
|
|
||||||
start-co
|
|
||||||
start-pn
|
|
||||||
@@ -1,915 +0,0 @@
|
|||||||
938,670
|
|
||||||
246,156
|
|
||||||
622,476
|
|
||||||
137,296
|
|
||||||
708,323
|
|
||||||
1019,283
|
|
||||||
415,505
|
|
||||||
1043,234
|
|
||||||
666,871
|
|
||||||
157,893
|
|
||||||
969,266
|
|
||||||
1280,690
|
|
||||||
987,260
|
|
||||||
296,428
|
|
||||||
1302,361
|
|
||||||
92,168
|
|
||||||
206,204
|
|
||||||
937,659
|
|
||||||
551,488
|
|
||||||
147,456
|
|
||||||
1279,42
|
|
||||||
463,154
|
|
||||||
407,266
|
|
||||||
1153,893
|
|
||||||
495,372
|
|
||||||
733,459
|
|
||||||
378,169
|
|
||||||
48,705
|
|
||||||
31,852
|
|
||||||
577,571
|
|
||||||
36,672
|
|
||||||
1014,661
|
|
||||||
441,880
|
|
||||||
1305,791
|
|
||||||
115,553
|
|
||||||
455,267
|
|
||||||
360,833
|
|
||||||
915,455
|
|
||||||
346,53
|
|
||||||
606,367
|
|
||||||
1014,513
|
|
||||||
930,633
|
|
||||||
190,350
|
|
||||||
564,577
|
|
||||||
1205,376
|
|
||||||
928,462
|
|
||||||
577,435
|
|
||||||
825,686
|
|
||||||
517,598
|
|
||||||
782,119
|
|
||||||
1110,539
|
|
||||||
67,236
|
|
||||||
77,185
|
|
||||||
577,723
|
|
||||||
808,855
|
|
||||||
139,742
|
|
||||||
865,414
|
|
||||||
159,522
|
|
||||||
1159,626
|
|
||||||
440,58
|
|
||||||
743,505
|
|
||||||
252,502
|
|
||||||
1190,659
|
|
||||||
855,521
|
|
||||||
1094,185
|
|
||||||
798,176
|
|
||||||
1114,61
|
|
||||||
174,695
|
|
||||||
427,581
|
|
||||||
161,670
|
|
||||||
74,222
|
|
||||||
1250,829
|
|
||||||
930,261
|
|
||||||
398,497
|
|
||||||
541,47
|
|
||||||
340,102
|
|
||||||
1057,614
|
|
||||||
820,753
|
|
||||||
1057,453
|
|
||||||
1158,141
|
|
||||||
492,499
|
|
||||||
267,234
|
|
||||||
642,568
|
|
||||||
904,586
|
|
||||||
1274,47
|
|
||||||
169,781
|
|
||||||
241,164
|
|
||||||
1037,621
|
|
||||||
50,254
|
|
||||||
44,63
|
|
||||||
388,561
|
|
||||||
1099,522
|
|
||||||
1255,809
|
|
||||||
736,171
|
|
||||||
1139,145
|
|
||||||
323,708
|
|
||||||
928,686
|
|
||||||
527,851
|
|
||||||
478,771
|
|
||||||
895,505
|
|
||||||
320,455
|
|
||||||
156,268
|
|
||||||
787,399
|
|
||||||
1136,695
|
|
||||||
150,751
|
|
||||||
252,537
|
|
||||||
1242,631
|
|
||||||
468,40
|
|
||||||
436,208
|
|
||||||
380,261
|
|
||||||
324,3
|
|
||||||
954,93
|
|
||||||
946,504
|
|
||||||
991,817
|
|
||||||
604,177
|
|
||||||
565,348
|
|
||||||
705,406
|
|
||||||
89,38
|
|
||||||
735,418
|
|
||||||
234,161
|
|
||||||
880,0
|
|
||||||
956,553
|
|
||||||
523,847
|
|
||||||
654,753
|
|
||||||
946,266
|
|
||||||
465,822
|
|
||||||
768,282
|
|
||||||
3,5
|
|
||||||
18,513
|
|
||||||
758,737
|
|
||||||
980,639
|
|
||||||
1248,725
|
|
||||||
1250,570
|
|
||||||
807,716
|
|
||||||
1138,375
|
|
||||||
1076,354
|
|
||||||
922,561
|
|
||||||
417,434
|
|
||||||
831,626
|
|
||||||
115,861
|
|
||||||
1255,710
|
|
||||||
793,473
|
|
||||||
77,499
|
|
||||||
964,169
|
|
||||||
989,343
|
|
||||||
875,183
|
|
||||||
758,224
|
|
||||||
398,397
|
|
||||||
1208,670
|
|
||||||
903,266
|
|
||||||
77,403
|
|
||||||
82,176
|
|
||||||
427,313
|
|
||||||
139,152
|
|
||||||
810,550
|
|
||||||
577,619
|
|
||||||
867,665
|
|
||||||
443,665
|
|
||||||
485,775
|
|
||||||
272,686
|
|
||||||
196,833
|
|
||||||
291,163
|
|
||||||
1029,387
|
|
||||||
1221,38
|
|
||||||
1019,611
|
|
||||||
544,78
|
|
||||||
299,826
|
|
||||||
1289,854
|
|
||||||
1160,751
|
|
||||||
1230,469
|
|
||||||
408,290
|
|
||||||
1056,176
|
|
||||||
281,507
|
|
||||||
170,828
|
|
||||||
18,828
|
|
||||||
1175,329
|
|
||||||
539,413
|
|
||||||
698,764
|
|
||||||
373,59
|
|
||||||
433,376
|
|
||||||
1020,504
|
|
||||||
85,771
|
|
||||||
151,716
|
|
||||||
934,245
|
|
||||||
172,792
|
|
||||||
383,78
|
|
||||||
1223,725
|
|
||||||
348,278
|
|
||||||
3,453
|
|
||||||
152,525
|
|
||||||
1037,618
|
|
||||||
1197,686
|
|
||||||
319,749
|
|
||||||
328,318
|
|
||||||
623,42
|
|
||||||
1258,521
|
|
||||||
441,14
|
|
||||||
862,802
|
|
||||||
1233,459
|
|
||||||
1140,791
|
|
||||||
994,509
|
|
||||||
417,262
|
|
||||||
517,712
|
|
||||||
1029,507
|
|
||||||
52,821
|
|
||||||
984,133
|
|
||||||
1120,96
|
|
||||||
1186,764
|
|
||||||
482,760
|
|
||||||
1114,754
|
|
||||||
190,96
|
|
||||||
728,494
|
|
||||||
1071,602
|
|
||||||
1019,122
|
|
||||||
92,726
|
|
||||||
1221,856
|
|
||||||
710,686
|
|
||||||
1140,49
|
|
||||||
485,208
|
|
||||||
661,775
|
|
||||||
774,511
|
|
||||||
154,123
|
|
||||||
383,816
|
|
||||||
986,3
|
|
||||||
455,409
|
|
||||||
200,614
|
|
||||||
584,749
|
|
||||||
616,662
|
|
||||||
493,353
|
|
||||||
572,649
|
|
||||||
80,171
|
|
||||||
932,177
|
|
||||||
1237,614
|
|
||||||
574,171
|
|
||||||
480,247
|
|
||||||
656,193
|
|
||||||
1153,449
|
|
||||||
502,257
|
|
||||||
1303,632
|
|
||||||
733,403
|
|
||||||
1274,672
|
|
||||||
872,515
|
|
||||||
219,631
|
|
||||||
353,9
|
|
||||||
1020,47
|
|
||||||
683,602
|
|
||||||
62,169
|
|
||||||
734,586
|
|
||||||
325,614
|
|
||||||
482,323
|
|
||||||
1160,143
|
|
||||||
987,5
|
|
||||||
982,766
|
|
||||||
1115,495
|
|
||||||
1086,894
|
|
||||||
441,546
|
|
||||||
816,675
|
|
||||||
1272,662
|
|
||||||
929,618
|
|
||||||
865,480
|
|
||||||
237,262
|
|
||||||
729,728
|
|
||||||
1197,159
|
|
||||||
880,289
|
|
||||||
68,148
|
|
||||||
816,227
|
|
||||||
924,198
|
|
||||||
113,686
|
|
||||||
704,245
|
|
||||||
745,486
|
|
||||||
500,550
|
|
||||||
510,824
|
|
||||||
817,353
|
|
||||||
708,571
|
|
||||||
1021,77
|
|
||||||
929,276
|
|
||||||
704,79
|
|
||||||
1061,51
|
|
||||||
1002,514
|
|
||||||
351,152
|
|
||||||
934,693
|
|
||||||
216,709
|
|
||||||
736,469
|
|
||||||
130,385
|
|
||||||
1221,546
|
|
||||||
276,254
|
|
||||||
1054,556
|
|
||||||
1164,7
|
|
||||||
2,107
|
|
||||||
812,626
|
|
||||||
610,383
|
|
||||||
1069,164
|
|
||||||
738,848
|
|
||||||
462,73
|
|
||||||
618,579
|
|
||||||
299,516
|
|
||||||
126,775
|
|
||||||
415,389
|
|
||||||
1044,113
|
|
||||||
1115,47
|
|
||||||
1062,586
|
|
||||||
746,129
|
|
||||||
976,397
|
|
||||||
1309,166
|
|
||||||
602,323
|
|
||||||
494,227
|
|
||||||
888,820
|
|
||||||
835,662
|
|
||||||
728,400
|
|
||||||
1009,397
|
|
||||||
410,718
|
|
||||||
273,618
|
|
||||||
253,453
|
|
||||||
865,59
|
|
||||||
528,775
|
|
||||||
1002,380
|
|
||||||
224,446
|
|
||||||
1305,327
|
|
||||||
364,166
|
|
||||||
189,744
|
|
||||||
67,658
|
|
||||||
1307,67
|
|
||||||
572,848
|
|
||||||
957,9
|
|
||||||
454,602
|
|
||||||
743,837
|
|
||||||
811,593
|
|
||||||
113,882
|
|
||||||
77,275
|
|
||||||
1232,138
|
|
||||||
482,326
|
|
||||||
216,653
|
|
||||||
987,827
|
|
||||||
984,761
|
|
||||||
1121,150
|
|
||||||
90,765
|
|
||||||
274,323
|
|
||||||
701,123
|
|
||||||
308,514
|
|
||||||
1159,178
|
|
||||||
80,723
|
|
||||||
1154,268
|
|
||||||
1255,16
|
|
||||||
20,77
|
|
||||||
745,856
|
|
||||||
729,726
|
|
||||||
628,229
|
|
||||||
475,662
|
|
||||||
120,659
|
|
||||||
1091,711
|
|
||||||
688,476
|
|
||||||
500,312
|
|
||||||
408,171
|
|
||||||
996,543
|
|
||||||
323,453
|
|
||||||
826,66
|
|
||||||
508,775
|
|
||||||
89,632
|
|
||||||
601,52
|
|
||||||
686,18
|
|
||||||
638,455
|
|
||||||
1094,67
|
|
||||||
562,509
|
|
||||||
102,593
|
|
||||||
517,312
|
|
||||||
435,263
|
|
||||||
594,829
|
|
||||||
930,323
|
|
||||||
1073,348
|
|
||||||
524,509
|
|
||||||
659,653
|
|
||||||
895,690
|
|
||||||
443,372
|
|
||||||
1149,670
|
|
||||||
763,408
|
|
||||||
160,227
|
|
||||||
36,628
|
|
||||||
571,28
|
|
||||||
687,70
|
|
||||||
1307,889
|
|
||||||
200,539
|
|
||||||
87,243
|
|
||||||
818,753
|
|
||||||
1230,873
|
|
||||||
152,173
|
|
||||||
408,738
|
|
||||||
219,711
|
|
||||||
890,845
|
|
||||||
606,79
|
|
||||||
1168,77
|
|
||||||
1200,78
|
|
||||||
688,154
|
|
||||||
335,184
|
|
||||||
629,173
|
|
||||||
793,712
|
|
||||||
318,571
|
|
||||||
769,686
|
|
||||||
1310,141
|
|
||||||
234,354
|
|
||||||
3,403
|
|
||||||
155,322
|
|
||||||
579,516
|
|
||||||
706,53
|
|
||||||
977,241
|
|
||||||
1178,652
|
|
||||||
1054,637
|
|
||||||
5,791
|
|
||||||
316,593
|
|
||||||
681,528
|
|
||||||
226,152
|
|
||||||
838,53
|
|
||||||
316,301
|
|
||||||
947,283
|
|
||||||
647,262
|
|
||||||
833,427
|
|
||||||
1014,233
|
|
||||||
1058,502
|
|
||||||
562,207
|
|
||||||
224,894
|
|
||||||
836,775
|
|
||||||
869,14
|
|
||||||
256,273
|
|
||||||
541,686
|
|
||||||
1227,345
|
|
||||||
1074,99
|
|
||||||
92,562
|
|
||||||
489,306
|
|
||||||
1149,801
|
|
||||||
172,760
|
|
||||||
811,301
|
|
||||||
1230,425
|
|
||||||
512,718
|
|
||||||
1084,152
|
|
||||||
213,14
|
|
||||||
813,445
|
|
||||||
628,665
|
|
||||||
1011,516
|
|
||||||
850,773
|
|
||||||
21,40
|
|
||||||
1033,406
|
|
||||||
783,43
|
|
||||||
719,840
|
|
||||||
1225,164
|
|
||||||
219,152
|
|
||||||
1222,173
|
|
||||||
1038,686
|
|
||||||
236,99
|
|
||||||
1220,99
|
|
||||||
761,824
|
|
||||||
909,814
|
|
||||||
740,756
|
|
||||||
676,278
|
|
||||||
219,183
|
|
||||||
1218,168
|
|
||||||
1233,485
|
|
||||||
281,682
|
|
||||||
403,465
|
|
||||||
672,455
|
|
||||||
1037,276
|
|
||||||
649,775
|
|
||||||
622,292
|
|
||||||
1303,262
|
|
||||||
435,94
|
|
||||||
68,631
|
|
||||||
402,201
|
|
||||||
326,133
|
|
||||||
574,51
|
|
||||||
986,891
|
|
||||||
1120,350
|
|
||||||
912,621
|
|
||||||
970,792
|
|
||||||
549,824
|
|
||||||
253,677
|
|
||||||
536,292
|
|
||||||
1290,177
|
|
||||||
28,190
|
|
||||||
356,93
|
|
||||||
842,40
|
|
||||||
769,208
|
|
||||||
653,877
|
|
||||||
1215,460
|
|
||||||
803,8
|
|
||||||
1262,245
|
|
||||||
417,348
|
|
||||||
865,507
|
|
||||||
1116,325
|
|
||||||
580,828
|
|
||||||
314,211
|
|
||||||
1233,185
|
|
||||||
582,624
|
|
||||||
818,499
|
|
||||||
661,464
|
|
||||||
726,749
|
|
||||||
933,488
|
|
||||||
77,459
|
|
||||||
604,702
|
|
||||||
454,7
|
|
||||||
435,711
|
|
||||||
416,873
|
|
||||||
1130,439
|
|
||||||
137,312
|
|
||||||
113,208
|
|
||||||
582,494
|
|
||||||
1138,102
|
|
||||||
924,310
|
|
||||||
281,387
|
|
||||||
569,663
|
|
||||||
652,143
|
|
||||||
353,885
|
|
||||||
602,633
|
|
||||||
816,219
|
|
||||||
606,649
|
|
||||||
191,565
|
|
||||||
55,464
|
|
||||||
846,96
|
|
||||||
422,759
|
|
||||||
253,441
|
|
||||||
560,311
|
|
||||||
36,679
|
|
||||||
1290,525
|
|
||||||
1158,173
|
|
||||||
333,775
|
|
||||||
704,649
|
|
||||||
527,857
|
|
||||||
692,579
|
|
||||||
72,176
|
|
||||||
584,690
|
|
||||||
562,687
|
|
||||||
1121,822
|
|
||||||
599,246
|
|
||||||
319,593
|
|
||||||
1124,488
|
|
||||||
657,877
|
|
||||||
457,675
|
|
||||||
1179,266
|
|
||||||
668,568
|
|
||||||
577,171
|
|
||||||
170,845
|
|
||||||
865,387
|
|
||||||
452,578
|
|
||||||
174,141
|
|
||||||
119,203
|
|
||||||
70,674
|
|
||||||
745,348
|
|
||||||
12,326
|
|
||||||
1240,749
|
|
||||||
239,389
|
|
||||||
574,313
|
|
||||||
709,52
|
|
||||||
542,282
|
|
||||||
31,824
|
|
||||||
110,368
|
|
||||||
182,219
|
|
||||||
353,437
|
|
||||||
755,133
|
|
||||||
1029,212
|
|
||||||
571,866
|
|
||||||
494,675
|
|
||||||
715,212
|
|
||||||
920,844
|
|
||||||
1181,667
|
|
||||||
704,525
|
|
||||||
20,369
|
|
||||||
729,814
|
|
||||||
1168,176
|
|
||||||
290,119
|
|
||||||
1196,143
|
|
||||||
748,338
|
|
||||||
1183,25
|
|
||||||
221,376
|
|
||||||
1258,883
|
|
||||||
331,226
|
|
||||||
700,383
|
|
||||||
731,516
|
|
||||||
649,430
|
|
||||||
227,502
|
|
||||||
783,3
|
|
||||||
959,152
|
|
||||||
440,836
|
|
||||||
726,369
|
|
||||||
70,749
|
|
||||||
1171,152
|
|
||||||
897,388
|
|
||||||
154,344
|
|
||||||
661,430
|
|
||||||
994,385
|
|
||||||
507,8
|
|
||||||
800,70
|
|
||||||
739,345
|
|
||||||
1192,511
|
|
||||||
478,751
|
|
||||||
853,890
|
|
||||||
298,821
|
|
||||||
808,39
|
|
||||||
687,852
|
|
||||||
254,176
|
|
||||||
127,473
|
|
||||||
1195,553
|
|
||||||
733,619
|
|
||||||
214,58
|
|
||||||
788,793
|
|
||||||
723,455
|
|
||||||
465,150
|
|
||||||
10,471
|
|
||||||
373,235
|
|
||||||
623,294
|
|
||||||
281,212
|
|
||||||
1016,173
|
|
||||||
912,257
|
|
||||||
1061,388
|
|
||||||
1190,235
|
|
||||||
546,656
|
|
||||||
378,389
|
|
||||||
676,616
|
|
||||||
1240,397
|
|
||||||
783,409
|
|
||||||
400,64
|
|
||||||
569,282
|
|
||||||
1292,841
|
|
||||||
663,262
|
|
||||||
1262,705
|
|
||||||
457,4
|
|
||||||
1232,308
|
|
||||||
226,742
|
|
||||||
649,327
|
|
||||||
952,381
|
|
||||||
567,651
|
|
||||||
724,263
|
|
||||||
940,316
|
|
||||||
956,240
|
|
||||||
53,500
|
|
||||||
1298,326
|
|
||||||
1016,866
|
|
||||||
1223,690
|
|
||||||
688,292
|
|
||||||
1076,332
|
|
||||||
632,782
|
|
||||||
454,740
|
|
||||||
131,495
|
|
||||||
152,141
|
|
||||||
989,653
|
|
||||||
189,488
|
|
||||||
1086,224
|
|
||||||
1072,873
|
|
||||||
651,515
|
|
||||||
870,58
|
|
||||||
932,169
|
|
||||||
1258,409
|
|
||||||
700,511
|
|
||||||
769,735
|
|
||||||
5,567
|
|
||||||
321,241
|
|
||||||
200,740
|
|
||||||
576,586
|
|
||||||
581,726
|
|
||||||
303,742
|
|
||||||
132,652
|
|
||||||
1014,428
|
|
||||||
380,633
|
|
||||||
330,815
|
|
||||||
73,280
|
|
||||||
1207,488
|
|
||||||
536,511
|
|
||||||
902,604
|
|
||||||
446,852
|
|
||||||
448,11
|
|
||||||
77,485
|
|
||||||
594,65
|
|
||||||
1039,78
|
|
||||||
708,11
|
|
||||||
482,550
|
|
||||||
331,345
|
|
||||||
373,771
|
|
||||||
333,103
|
|
||||||
959,742
|
|
||||||
1220,795
|
|
||||||
36,215
|
|
||||||
848,821
|
|
||||||
726,145
|
|
||||||
482,568
|
|
||||||
682,665
|
|
||||||
937,771
|
|
||||||
298,353
|
|
||||||
774,383
|
|
||||||
28,373
|
|
||||||
826,49
|
|
||||||
364,266
|
|
||||||
716,0
|
|
||||||
883,581
|
|
||||||
1094,795
|
|
||||||
212,306
|
|
||||||
136,789
|
|
||||||
401,814
|
|
||||||
659,889
|
|
||||||
422,74
|
|
||||||
541,208
|
|
||||||
20,817
|
|
||||||
364,728
|
|
||||||
785,785
|
|
||||||
937,212
|
|
||||||
1104,204
|
|
||||||
74,290
|
|
||||||
855,309
|
|
||||||
7,856
|
|
||||||
587,439
|
|
||||||
663,38
|
|
||||||
174,199
|
|
||||||
282,679
|
|
||||||
1120,798
|
|
||||||
845,582
|
|
||||||
290,847
|
|
||||||
92,332
|
|
||||||
1243,236
|
|
||||||
1020,266
|
|
||||||
443,105
|
|
||||||
497,449
|
|
||||||
728,270
|
|
||||||
124,764
|
|
||||||
1280,513
|
|
||||||
535,203
|
|
||||||
741,771
|
|
||||||
278,201
|
|
||||||
708,633
|
|
||||||
599,269
|
|
||||||
842,854
|
|
||||||
994,301
|
|
||||||
18,841
|
|
||||||
324,891
|
|
||||||
480,641
|
|
||||||
740,138
|
|
||||||
95,882
|
|
||||||
734,308
|
|
||||||
577,282
|
|
||||||
793,296
|
|
||||||
932,389
|
|
||||||
705,488
|
|
||||||
52,521
|
|
||||||
180,455
|
|
||||||
1190,540
|
|
||||||
581,814
|
|
||||||
420,637
|
|
||||||
160,667
|
|
||||||
478,359
|
|
||||||
190,798
|
|
||||||
150,143
|
|
||||||
130,826
|
|
||||||
89,348
|
|
||||||
569,123
|
|
||||||
771,301
|
|
||||||
853,442
|
|
||||||
1146,753
|
|
||||||
733,395
|
|
||||||
348,333
|
|
||||||
441,287
|
|
||||||
216,99
|
|
||||||
3,67
|
|
||||||
176,183
|
|
||||||
547,856
|
|
||||||
68,711
|
|
||||||
605,406
|
|
||||||
544,627
|
|
||||||
105,152
|
|
||||||
856,103
|
|
||||||
1032,201
|
|
||||||
618,131
|
|
||||||
599,878
|
|
||||||
604,841
|
|
||||||
1233,275
|
|
||||||
479,626
|
|
||||||
1151,522
|
|
||||||
21,854
|
|
||||||
668,543
|
|
||||||
1028,740
|
|
||||||
113,159
|
|
||||||
746,577
|
|
||||||
586,863
|
|
||||||
1247,840
|
|
||||||
272,208
|
|
||||||
201,138
|
|
||||||
249,58
|
|
||||||
159,372
|
|
||||||
87,725
|
|
||||||
776,540
|
|
||||||
907,579
|
|
||||||
1099,677
|
|
||||||
468,854
|
|
||||||
748,687
|
|
||||||
303,152
|
|
||||||
1094,241
|
|
||||||
52,373
|
|
||||||
85,739
|
|
||||||
48,189
|
|
||||||
52,883
|
|
||||||
157,445
|
|
||||||
430,0
|
|
||||||
185,234
|
|
||||||
127,627
|
|
||||||
6,887
|
|
||||||
527,627
|
|
||||||
582,176
|
|
||||||
1118,521
|
|
||||||
216,67
|
|
||||||
386,198
|
|
||||||
1150,227
|
|
||||||
172,344
|
|
||||||
687,600
|
|
||||||
120,690
|
|
||||||
387,712
|
|
||||||
1203,632
|
|
||||||
888,123
|
|
||||||
689,676
|
|
||||||
468,488
|
|
||||||
933,770
|
|
||||||
199,267
|
|
||||||
256,497
|
|
||||||
586,263
|
|
||||||
895,389
|
|
||||||
110,627
|
|
||||||
479,268
|
|
||||||
741,730
|
|
||||||
694,232
|
|
||||||
666,301
|
|
||||||
704,490
|
|
||||||
129,667
|
|
||||||
1242,711
|
|
||||||
830,641
|
|
||||||
194,325
|
|
||||||
618,315
|
|
||||||
910,64
|
|
||||||
1052,298
|
|
||||||
1171,742
|
|
||||||
869,546
|
|
||||||
1153,880
|
|
||||||
1148,128
|
|
||||||
381,173
|
|
||||||
1233,11
|
|
||||||
1240,130
|
|
||||||
103,488
|
|
||||||
274,267
|
|
||||||
402,693
|
|
||||||
594,381
|
|
||||||
495,267
|
|
||||||
246,425
|
|
||||||
1292,268
|
|
||||||
602,37
|
|
||||||
539,677
|
|
||||||
793,421
|
|
||||||
711,16
|
|
||||||
89,856
|
|
||||||
1073,460
|
|
||||||
1020,180
|
|
||||||
763,856
|
|
||||||
438,205
|
|
||||||
365,817
|
|
||||||
1210,600
|
|
||||||
372,224
|
|
||||||
135,565
|
|
||||||
853,452
|
|
||||||
239,242
|
|
||||||
363,283
|
|
||||||
1079,348
|
|
||||||
142,176
|
|
||||||
107,632
|
|
||||||
534,242
|
|
||||||
530,130
|
|
||||||
142,77
|
|
||||||
1290,77
|
|
||||||
1218,385
|
|
||||||
249,51
|
|
||||||
214,57
|
|
||||||
687,42
|
|
||||||
972,77
|
|
||||||
1173,296
|
|
||||||
808,305
|
|
||||||
813,1
|
|
||||||
1225,155
|
|
||||||
333,791
|
|
||||||
774,607
|
|
||||||
1300,23
|
|
||||||
1140,103
|
|
||||||
340,550
|
|
||||||
154,582
|
|
||||||
10,423
|
|
||||||
38,662
|
|
||||||
565,856
|
|
||||||
354,688
|
|
||||||
333,241
|
|
||||||
1256,208
|
|
||||||
272,656
|
|
||||||
736,51
|
|
||||||
880,672
|
|
||||||
1145,894
|
|
||||||
1022,379
|
|
||||||
566,721
|
|
||||||
668,102
|
|
||||||
503,716
|
|
||||||
912,497
|
|
||||||
610,511
|
|
||||||
1292,828
|
|
||||||
282,222
|
|
||||||
22,782
|
|
||||||
572,718
|
|
||||||
|
|
||||||
fold along x=655
|
|
||||||
fold along y=447
|
|
||||||
fold along x=327
|
|
||||||
fold along y=223
|
|
||||||
fold along x=163
|
|
||||||
fold along y=111
|
|
||||||
fold along x=81
|
|
||||||
fold along y=55
|
|
||||||
fold along x=40
|
|
||||||
fold along y=27
|
|
||||||
fold along y=13
|
|
||||||
fold along y=6
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
PHVCVBFHCVPFKBNHKNBO
|
|
||||||
|
|
||||||
HK -> F
|
|
||||||
VN -> S
|
|
||||||
NB -> F
|
|
||||||
HF -> B
|
|
||||||
CK -> N
|
|
||||||
VP -> B
|
|
||||||
HO -> P
|
|
||||||
NH -> N
|
|
||||||
CC -> N
|
|
||||||
FC -> P
|
|
||||||
OK -> S
|
|
||||||
OO -> P
|
|
||||||
ON -> C
|
|
||||||
VF -> B
|
|
||||||
NN -> O
|
|
||||||
KS -> P
|
|
||||||
FK -> K
|
|
||||||
HB -> V
|
|
||||||
SH -> O
|
|
||||||
OB -> K
|
|
||||||
PB -> V
|
|
||||||
BO -> O
|
|
||||||
NV -> K
|
|
||||||
CV -> H
|
|
||||||
PH -> H
|
|
||||||
KO -> B
|
|
||||||
BC -> B
|
|
||||||
KC -> B
|
|
||||||
SO -> P
|
|
||||||
CF -> V
|
|
||||||
VS -> F
|
|
||||||
OV -> N
|
|
||||||
NS -> K
|
|
||||||
KV -> O
|
|
||||||
OP -> O
|
|
||||||
HH -> C
|
|
||||||
FB -> S
|
|
||||||
CO -> K
|
|
||||||
SB -> K
|
|
||||||
SN -> V
|
|
||||||
OF -> F
|
|
||||||
BN -> F
|
|
||||||
CP -> C
|
|
||||||
NC -> H
|
|
||||||
VH -> S
|
|
||||||
HV -> V
|
|
||||||
NF -> B
|
|
||||||
SS -> K
|
|
||||||
FO -> F
|
|
||||||
VO -> H
|
|
||||||
KK -> C
|
|
||||||
PF -> V
|
|
||||||
OS -> F
|
|
||||||
OC -> H
|
|
||||||
SK -> V
|
|
||||||
FF -> H
|
|
||||||
PK -> N
|
|
||||||
PC -> O
|
|
||||||
SP -> B
|
|
||||||
CB -> B
|
|
||||||
CH -> H
|
|
||||||
FN -> V
|
|
||||||
SV -> O
|
|
||||||
SC -> P
|
|
||||||
NP -> B
|
|
||||||
BB -> S
|
|
||||||
PV -> S
|
|
||||||
VB -> P
|
|
||||||
SF -> H
|
|
||||||
VC -> O
|
|
||||||
HN -> V
|
|
||||||
BF -> O
|
|
||||||
NO -> O
|
|
||||||
HP -> N
|
|
||||||
VV -> K
|
|
||||||
HS -> P
|
|
||||||
FH -> N
|
|
||||||
KB -> F
|
|
||||||
KF -> B
|
|
||||||
PN -> K
|
|
||||||
KH -> K
|
|
||||||
CN -> S
|
|
||||||
PP -> O
|
|
||||||
BP -> O
|
|
||||||
OH -> B
|
|
||||||
FS -> O
|
|
||||||
BK -> B
|
|
||||||
PO -> V
|
|
||||||
CS -> C
|
|
||||||
BV -> N
|
|
||||||
KP -> O
|
|
||||||
KN -> B
|
|
||||||
VK -> F
|
|
||||||
HC -> O
|
|
||||||
BH -> B
|
|
||||||
FP -> H
|
|
||||||
NK -> V
|
|
||||||
BS -> C
|
|
||||||
FV -> F
|
|
||||||
PS -> P
|
|
||||||
@@ -32,7 +32,7 @@ class Condition : ExecutionCondition {
|
|||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
@ExtendWith(Condition::class)
|
@ExtendWith(Condition::class)
|
||||||
abstract class BaseDayTest() {
|
abstract class BaseDayTest(day: Int) {
|
||||||
|
|
||||||
abstract val example: String
|
abstract val example: String
|
||||||
|
|
||||||
@@ -46,11 +46,7 @@ abstract class BaseDayTest() {
|
|||||||
BeanContext.run()
|
BeanContext.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val day by lazy(LazyThreadSafetyMode.NONE) {
|
val instance by lazy { ctx.value.getBean(ctx.value.findDayDefinition(day)) }
|
||||||
this::class.java.simpleName.replace("Day", "").replace("Test", "").toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
val instance by lazy { ctx.value.getBean(ctx.value.findDayDefinition(day)!!) }
|
|
||||||
|
|
||||||
private val exampleCtx = lazy {
|
private val exampleCtx = lazy {
|
||||||
BeanContext.build()
|
BeanContext.build()
|
||||||
@@ -58,7 +54,7 @@ abstract class BaseDayTest() {
|
|||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
val exampleInstance by lazy { exampleCtx.value.getBean(exampleCtx.value.findDayDefinition(day)!!) }
|
val exampleInstance by lazy { exampleCtx.value.getBean(exampleCtx.value.findDayDefinition(day)) }
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun `after all`() {
|
fun `after all`() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day01Test : BaseDayTest() {
|
class Day01Test : BaseDayTest(1) {
|
||||||
override val example = """
|
override val example = """
|
||||||
199
|
199
|
||||||
200
|
200
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day02Test : BaseDayTest() {
|
class Day02Test : BaseDayTest(2) {
|
||||||
override val example = """
|
override val example = """
|
||||||
forward 5
|
forward 5
|
||||||
down 5
|
down 5
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day03Test : BaseDayTest() {
|
class Day03Test : BaseDayTest(3) {
|
||||||
override val example = """
|
override val example = """
|
||||||
00100
|
00100
|
||||||
11110
|
11110
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day04Test : BaseDayTest() {
|
class Day04Test : BaseDayTest(4) {
|
||||||
override val example = """
|
override val example = """
|
||||||
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
|
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day05Test : BaseDayTest() {
|
class Day05Test : BaseDayTest(5) {
|
||||||
override val example = """
|
override val example = """
|
||||||
0,9 -> 5,9
|
0,9 -> 5,9
|
||||||
8,0 -> 0,8
|
8,0 -> 0,8
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day06Test : BaseDayTest() {
|
class Day06Test : BaseDayTest(6) {
|
||||||
override val example = """
|
override val example = """
|
||||||
3,4,3,1,2
|
3,4,3,1,2
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day07Test : BaseDayTest() {
|
class Day07Test : BaseDayTest(7) {
|
||||||
override val example = """
|
override val example = """
|
||||||
16,1,2,0,4,2,7,1,2,14
|
16,1,2,0,4,2,7,1,2,14
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day08Test : BaseDayTest() {
|
class Day08Test : BaseDayTest(8) {
|
||||||
override val example = """
|
override val example = """
|
||||||
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
|
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
|
||||||
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
|
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day09Test : BaseDayTest() {
|
class Day09Test : BaseDayTest(9) {
|
||||||
override val example = """
|
override val example = """
|
||||||
2199943210
|
2199943210
|
||||||
3987894921
|
3987894921
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package be.vandewalleh.aoc.days
|
package be.vandewalleh.aoc.days
|
||||||
|
|
||||||
class Day10Test : BaseDayTest() {
|
class Day10Test : BaseDayTest(10) {
|
||||||
override val example = """
|
override val example = """
|
||||||
[({(<(())[]>[[{[]{<()<>>
|
[({(<(())[]>[[{[]{<()<>>
|
||||||
[(()[<>])]({[<{<<[]>>(
|
[(()[<>])]({[<{<<[]>>(
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
class Day11Test : BaseDayTest() {
|
|
||||||
override val example = """
|
|
||||||
5483143223
|
|
||||||
2745854711
|
|
||||||
5264556173
|
|
||||||
6141336146
|
|
||||||
6357385478
|
|
||||||
4167524645
|
|
||||||
2176841721
|
|
||||||
6882881134
|
|
||||||
4846848554
|
|
||||||
5283751526
|
|
||||||
""".trimIndent()
|
|
||||||
|
|
||||||
override val part1Example = 1656
|
|
||||||
override val part1Answer = 1661
|
|
||||||
|
|
||||||
override val part2Example = 195
|
|
||||||
override val part2Answer = 334
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
class Day12Test : BaseDayTest() {
|
|
||||||
override val example = """
|
|
||||||
start-A
|
|
||||||
start-b
|
|
||||||
A-c
|
|
||||||
A-b
|
|
||||||
b-d
|
|
||||||
A-end
|
|
||||||
b-end
|
|
||||||
""".trimIndent()
|
|
||||||
|
|
||||||
override val part1Example = 10
|
|
||||||
override val part1Answer = 4413
|
|
||||||
|
|
||||||
override val part2Example = 36
|
|
||||||
override val part2Answer = 118803
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package be.vandewalleh.aoc.days
|
|
||||||
|
|
||||||
class Day14Test : BaseDayTest() {
|
|
||||||
override val example = """
|
|
||||||
NNCB
|
|
||||||
|
|
||||||
CH -> B
|
|
||||||
HH -> N
|
|
||||||
CB -> H
|
|
||||||
NH -> C
|
|
||||||
HB -> C
|
|
||||||
HC -> B
|
|
||||||
HN -> C
|
|
||||||
NN -> C
|
|
||||||
BH -> H
|
|
||||||
NC -> B
|
|
||||||
NB -> B
|
|
||||||
BN -> B
|
|
||||||
BB -> N
|
|
||||||
BC -> B
|
|
||||||
CC -> N
|
|
||||||
CN -> C
|
|
||||||
""".trimIndent()
|
|
||||||
|
|
||||||
override val part1Example = 1588L
|
|
||||||
override val part1Answer = 3555L
|
|
||||||
|
|
||||||
override val part2Example = 2188189693529
|
|
||||||
override val part2Answer = 4439442043739
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,10 @@ plugins {
|
|||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlinDslPluginOptions {
|
||||||
|
experimentalWarning.set(false)
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven { setUrl("https://kotlin.bintray.com/kotlinx") }
|
maven { setUrl("https://kotlin.bintray.com/kotlinx") }
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("kotlin-convention")
|
|
||||||
kotlin("kapt")
|
|
||||||
id("application")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":utils"))
|
|
||||||
|
|
||||||
kapt(Libs.Micronaut.processor)
|
|
||||||
|
|
||||||
implementation(Libs.Slf4J.api)
|
|
||||||
runtimeOnly(Libs.Slf4J.simple)
|
|
||||||
|
|
||||||
implementation(Libs.eclipseCollections)
|
|
||||||
|
|
||||||
testImplementation(Libs.Jmh.core)
|
|
||||||
testImplementation(Libs.Slf4J.simple)
|
|
||||||
kaptTest(Libs.Jmh.processor)
|
|
||||||
kaptTest(Libs.Slf4J.simple)
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ plugins {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
maven { url = uri("https://dl.bintray.com/arrow-kt/arrow-kt/") }
|
maven { url = uri("https://dl.bintray.com/arrow-kt/arrow-kt/") }
|
||||||
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
|
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package be.vandewalleh.aoc.utils
|
|||||||
import be.vandewalleh.aoc.utils.factory.findDayDefinition
|
import be.vandewalleh.aoc.utils.factory.findDayDefinition
|
||||||
import io.micronaut.context.BeanContext
|
import io.micronaut.context.BeanContext
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import kotlin.system.measureTimeMillis
|
|
||||||
|
|
||||||
fun runDay(day: Int = LocalDate.now().dayOfMonth) {
|
fun runDay(day: Int = LocalDate.now().dayOfMonth) {
|
||||||
val ctx = BeanContext.run()
|
val ctx = BeanContext.run()
|
||||||
@@ -15,20 +14,23 @@ fun runDay(day: Int = LocalDate.now().dayOfMonth) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val instance = ctx.getBean(definition)
|
val instance = ctx.getBean(definition)
|
||||||
|
val part1Handle = ctx.findExecutionHandle<Any, Any>(instance, "part1")
|
||||||
|
if (part1Handle.isEmpty) {
|
||||||
|
println("part1() not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
println("*** Day $day ***")
|
println("*** Day $day ***")
|
||||||
|
println()
|
||||||
|
println("part 1:")
|
||||||
|
println(part1Handle.get().invoke())
|
||||||
|
|
||||||
val p1: Any
|
println()
|
||||||
val ms1 = measureTimeMillis {
|
val part2Handle = ctx.findExecutionHandle<Any, Any>(instance, "part2")
|
||||||
p1 = instance.part1()
|
if (part2Handle.isEmpty) {
|
||||||
|
println("part2() not found")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
println("part 1 ($ms1 ms):")
|
println("part 2:")
|
||||||
println(p1)
|
println(part2Handle.get().invoke())
|
||||||
|
|
||||||
val p2: Any
|
|
||||||
val ms2 = measureTimeMillis {
|
|
||||||
p2 = instance.part2()
|
|
||||||
}
|
|
||||||
println("part 2 ($ms2 ms):")
|
|
||||||
println(p2)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package be.vandewalleh.aoc.utils.input
|
package be.vandewalleh.aoc.utils.input
|
||||||
|
|
||||||
|
import io.micronaut.context.annotation.Executable
|
||||||
import io.micronaut.context.annotation.Prototype
|
import io.micronaut.context.annotation.Prototype
|
||||||
import io.micronaut.core.annotation.Introspected
|
import io.micronaut.core.annotation.Introspected
|
||||||
import jakarta.inject.Qualifier
|
import jakarta.inject.Qualifier
|
||||||
@@ -11,4 +12,5 @@ import jakarta.inject.Qualifier
|
|||||||
@Introspected
|
@Introspected
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@Executable
|
||||||
annotation class Day(val value: Int = -1)
|
annotation class Day(val value: Int = -1)
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package be.vandewalleh.aoc.utils.input
|
package be.vandewalleh.aoc.utils.input
|
||||||
|
|
||||||
import org.intellij.lang.annotations.Language
|
|
||||||
|
|
||||||
class Input(private val value: String) {
|
class Input(private val value: String) {
|
||||||
val text get() = value
|
val text get() = value
|
||||||
|
|
||||||
val lines get() = Mapper(value.lines())
|
val lines get() = Mapper(value.lines())
|
||||||
val csv get() = Mapper(value.split(','))
|
val csv get() = Mapper(value.split(','))
|
||||||
|
|
||||||
fun findAll(@Language("RegExp") re: String): List<List<String>> =
|
|
||||||
re.toRegex().findAll(value).map { it.groupValues.drop(1) }.toList()
|
|
||||||
|
|
||||||
class Mapper(val value: List<String>) {
|
class Mapper(val value: List<String>) {
|
||||||
val ints get() = value.map { it.toInt() }
|
val ints get() = value.map { it.toInt() }
|
||||||
val longs get() = value.map { it.toLong() }
|
val longs get() = value.map { it.toLong() }
|
||||||
|
|||||||
Reference in New Issue
Block a user