~macaptain/advent-of-code

57eba89652e9b380e02c9b06b725b0d5a3fb2bf3 — Michael Captain 1 year, 3 months ago 43fbd43
Refactor input across years; set up Advent of Code 2022
64 files changed, 310 insertions(+), 150 deletions(-)

M .idea/kotlinc.xml
M pom.xml
M src/main/advent2017/Day01.kt
M src/main/advent2017/Day02.kt
M src/main/advent2017/Day03.kt
M src/main/advent2017/Day04.kt
M src/main/advent2017/Day05.kt
M src/main/advent2017/Day06.kt
M src/main/advent2017/Day07.kt
M src/main/advent2017/Day08.kt
M src/main/advent2017/Day09.kt
M src/main/advent2017/Day10.kt
M src/main/advent2017/Day11.kt
M src/main/advent2017/Day12.kt
M src/main/advent2017/Day13.kt
M src/main/advent2017/Day14.kt
M src/main/advent2017/Day15.kt
M src/main/advent2017/Day16.kt
M src/main/advent2017/Day17.kt
M src/main/advent2017/Day18.kt
M src/main/advent2017/Day19.kt
M src/main/advent2017/Day20.kt
M src/main/advent2017/Day21.kt
M src/main/advent2017/Day22.kt
M src/main/advent2017/Day23.kt
M src/main/advent2017/Day24.kt
M src/main/advent2017/Day25.kt
A src/main/advent2017/Input.kt
M src/main/advent2018/Input.kt
M src/main/advent2019/Input.kt
M src/main/advent2019/Intcode.kt
M src/main/advent2020/Day04.kt
M src/main/advent2020/Day16.kt
M src/main/advent2020/Day19.kt
M src/main/advent2020/Input.kt
M src/main/advent2021/Input.kt
A src/main/advent2022/Input.kt
A src/main/common/Input.kt
A src/main/resources/advent2017/day01_input.txt
A src/main/resources/advent2017/day02_input.txt
A src/main/resources/advent2017/day03_input.txt
R src/main/resources/advent2017/{day4_input => day04_input.txt}
R src/main/resources/advent2017/{day5_input => day05_input.txt}
A src/main/resources/advent2017/day06_input.txt
R src/main/resources/advent2017/{day7_input => day07_input.txt}
R src/main/resources/advent2017/{day8_input => day08_input.txt}
R src/main/resources/advent2017/{day9_input => day09_input.txt}
A src/main/resources/advent2017/day10_input.txt
R src/main/resources/advent2017/{day11_input => day11_input.txt}
R src/main/resources/advent2017/{day12_input => day12_input.txt}
R src/main/resources/advent2017/{day13_input => day13_input.txt}
A src/main/resources/advent2017/day14_input.txt
R src/main/resources/advent2017/{day15_input => day15_input.txt}
R src/main/resources/advent2017/{day16_input => day16_input.txt}
A src/main/resources/advent2017/day17_input.txt
R src/main/resources/advent2017/{day18_input => day18_input.txt}
R src/main/resources/advent2017/{day19_input => day19_input.txt}
R src/main/resources/advent2017/{day20_input => day20_input.txt}
A src/main/resources/advent2017/day21_input.txt
R src/main/resources/advent2017/{day22_input => day22_input.txt}
R src/main/resources/advent2017/{day23_input => day23_input.txt}
R src/main/resources/advent2017/{day24_input => day24_input.txt}
M src/test/advent2017/Day12KtTest.kt
M src/test/advent2017/Day21KtTest.kt
M .idea/kotlinc.xml => .idea/kotlinc.xml +3 -0
@@ 3,4 3,7 @@
  <component name="Kotlin2JvmCompilerArguments">
    <option name="jvmTarget" value="17" />
  </component>
  <component name="KotlinJpsPluginSettings">
    <option name="version" value="1.7.22" />
  </component>
</project>
\ No newline at end of file

M pom.xml => pom.xml +7 -1
@@ 12,7 12,8 @@

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.7.10</kotlin.version>
        <kotlin.version>1.7.22</kotlin.version>
        <kotlinx.version>1.6.4</kotlinx.version>
        <junit.version>5.8.2</junit.version>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
        <kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>


@@ 27,6 28,11 @@
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core</artifactId>
            <version>${kotlinx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <version>${kotlin.version}</version>

M src/main/advent2017/Day01.kt => src/main/advent2017/Day01.kt +3 -3
@@ 21,7 21,7 @@ fun solve1b(s: String): Int {
}

fun main() {
    val input = readLine()!!
    println(solve1a(input))
    println(solve1b(input))
    val input = input("day01").first()
    println(solve1a(input)) // 1203
    println(solve1b(input)) // 1146
}

M src/main/advent2017/Day02.kt => src/main/advent2017/Day02.kt +4 -5
@@ 30,8 30,7 @@ fun solve2b(xs: List<String>): Int {
}

fun main() {
    val xs = mutableListOf<String>()
    for (i in 0..15) xs.add(readLine()!!)
    println(solve2a(xs))
    println(solve2b(xs))
}
\ No newline at end of file
    val xs = input("day02")
    println(solve2a(xs)) // 51833
    println(solve2b(xs)) // 288
}

M src/main/advent2017/Day03.kt => src/main/advent2017/Day03.kt +4 -4
@@ 78,7 78,7 @@ fun solve3b(n: Int): Int {
}

fun main() {
    val input = readLine()!!.toInt()
    println(solve3a(input))
    println(solve3b(input))
}
\ No newline at end of file
    val input = input("day03").first().toInt()
    println(solve3a(input)) // 475
    println(solve3b(input)) // 279138
}

M src/main/advent2017/Day04.kt => src/main/advent2017/Day04.kt +4 -4
@@ 25,7 25,7 @@ fun solve4b(xs: List<String>): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day4_input").readLines()
    println(solve4a(input))
    println(solve4b(input))
}
\ No newline at end of file
    val input = input("day04")
    println(solve4a(input)) // 386
    println(solve4b(input)) // 208
}

M src/main/advent2017/Day05.kt => src/main/advent2017/Day05.kt +7 -5
@@ 2,7 2,8 @@ package advent2017

import java.io.File

fun solve5a(xs: MutableList<Int>): Int {
fun solve5a(input: List<Int>): Int {
    val xs = input.toMutableList()
    var count = 0
    var index = 0
    while (true) {


@@ 17,7 18,8 @@ fun solve5a(xs: MutableList<Int>): Int {
    }
}

fun solve5b(xs: MutableList<Int>): Int {
fun solve5b(input: List<Int>): Int {
    val xs = input.toMutableList()
    var count = 0
    var index = 0
    while (true) {


@@ 34,7 36,7 @@ fun solve5b(xs: MutableList<Int>): Int {


fun main() {
    val input = File("src/main/resources/advent2017/day5_input").readLines().map { it.toInt() }
    println(solve5a(input.toMutableList()))
    println(solve5b(input.toMutableList()))
    val input = input("day05").map { it.toInt() }
    println(solve5a(input)) // 339351
    println(solve5b(input)) // 24315397
}

M src/main/advent2017/Day06.kt => src/main/advent2017/Day06.kt +4 -4
@@ 29,7 29,7 @@ fun solve6b(xs: List<Int>): Int {
}

fun main() {
    val input = readLine()!!.split("\t").map { it.toInt() }
    println(solve6a(input))
    println(solve6b(input))
}
\ No newline at end of file
    val input = input("day06").first().split("\t").map { it.toInt() }
    println(solve6a(input)) // 6681
    println(solve6b(input)) // 2392
}

M src/main/advent2017/Day07.kt => src/main/advent2017/Day07.kt +4 -4
@@ 72,7 72,7 @@ fun solve7b(lines: List<String>): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day7_input").readLines()
    println(solve7a(input))
    println(solve7b(input))
}
\ No newline at end of file
    val input = input("day07")
    println(solve7a(input)) // uownj
    println(solve7b(input)) // 596
}

M src/main/advent2017/Day08.kt => src/main/advent2017/Day08.kt +3 -3
@@ 49,8 49,8 @@ fun solve8b(lines: List<String>): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day8_input").readLines()
    println(solve8a(input))
    println(solve8b(input))
    val input = input("day08")
    println(solve8a(input)) // 2971
    println(solve8b(input)) // 4254
}


M src/main/advent2017/Day09.kt => src/main/advent2017/Day09.kt +4 -4
@@ 31,7 31,7 @@ fun solve9b(input: String): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day9_input").readText()
    println(solve9a(input))
    println(solve9b(input))
}
\ No newline at end of file
    val input = input("day09").first()
    println(solve9a(input)) // 17390
    println(solve9b(input)) // 7825
}

M src/main/advent2017/Day10.kt => src/main/advent2017/Day10.kt +3 -3
@@ 59,8 59,8 @@ fun solve10b(input: String): String {
}

fun main() {
    val input = readLine()!!
    println(solve10a(input, 256))
    println(solve10b(input))
    val input = input("day10").first()
    println(solve10a(input, 256)) // 48705
    println(solve10b(input)) // 1c46642b6f2bc21db2a2149d0aeeae5d
}


M src/main/advent2017/Day11.kt => src/main/advent2017/Day11.kt +4 -4
@@ 42,7 42,7 @@ fun solve11b(s: String): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day11_input").readText()
    println(solve11a(input))
    println(solve11b(input))
}
\ No newline at end of file
    val input = input("day11").first()
    println(solve11a(input)) // 784
    println(solve11b(input)) // 1558
}

M src/main/advent2017/Day12.kt => src/main/advent2017/Day12.kt +6 -8
@@ 22,8 22,7 @@ fun getGroup(startingVillage: Village): Set<Village> {
    return visited
}

fun solve12a(s: String): Int {
    val lines = s.split("\n")
fun solve12a(lines: List<String>): Int {
    val villages = (0 until lines.count()).map { Village(it) }
    lines.forEach {
        val (id, pipes) = it.split(" <-> ")


@@ 34,8 33,7 @@ fun solve12a(s: String): Int {
    return getGroup(villages[0]).count()
}

fun solve12b(s: String): Int {
    val lines = s.split("\n")
fun solve12b(lines: List<String>): Int {
    val villages = (0 until lines.count()).map { Village(it) }
    lines.forEach {
        val (id, pipes) = it.split(" <-> ")


@@ 55,7 53,7 @@ fun solve12b(s: String): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day12_input").readText()
    println(solve12a(input))
    println(solve12b(input))
}
\ No newline at end of file
    val input = input("day12")
    println(solve12a(input)) // 130
    println(solve12b(input)) // 189
}

M src/main/advent2017/Day13.kt => src/main/advent2017/Day13.kt +4 -4
@@ 63,7 63,7 @@ fun solve13b(lines: List<String>): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day13_input").readText()
    println(solve13a(input.split("\n").filter { it.isNotEmpty() }))
    println(solve13b(input.split("\n").filter { it.isNotEmpty() }))
}
\ No newline at end of file
    val input = input("day13")
    println(solve13a(input)) // 3184
    println(solve13b(input)) // 3878062
}

M src/main/advent2017/Day14.kt => src/main/advent2017/Day14.kt +4 -3
@@ 40,6 40,7 @@ fun solve14b(input: String): Int {
}

fun main() {
    val input = readLine()!!
    println(solve14b(input))
}
\ No newline at end of file
    val input = input("day14").first()
    println(solve14a(input)) // 8106
    println(solve14b(input)) // 1164
}

M src/main/advent2017/Day15.kt => src/main/advent2017/Day15.kt +3 -3
@@ 50,6 50,6 @@ fun solve15b(initialA: Long, initialB: Long, repeats: Int): Int {


fun main() {
    println(solve15a(703, 516, 40_000_000))
    println(solve15b(703, 516, 5_000_000))
}
\ No newline at end of file
    println(solve15a(703, 516, 40_000_000)) // 594
    println(solve15b(703, 516, 5_000_000)) // 328
}

M src/main/advent2017/Day16.kt => src/main/advent2017/Day16.kt +4 -4
@@ 63,7 63,7 @@ fun solve16b(s: String): String {
}

fun main() {
    val input = File("src/main/resources/advent2017/day16_input").readText()
    println(solve16a(input))
    println(solve16b(input))
}
\ No newline at end of file
    val input = input("day16").first()
    println(solve16a(input)) // kbednhopmfcjilag
    println(solve16b(input)) // fbmcgdnjakpioelh
}

M src/main/advent2017/Day17.kt => src/main/advent2017/Day17.kt +4 -4
@@ 33,7 33,7 @@ fun solve17b(step: Int): Int {
}

fun main() {
    val input = readLine()!!
    println(solve17a(input.toInt()))
    println(solve17b(input.toInt()))
}
\ No newline at end of file
    val input = input("day17").first().toInt()
    println(solve17a(input)) // 1670
    println(solve17b(input)) // 2316253
}

M src/main/advent2017/Day18.kt => src/main/advent2017/Day18.kt +21 -11
@@ 1,6 1,5 @@
package advent2017

import java.io.File
import java.math.BigInteger
import java.util.concurrent.ConcurrentLinkedQueue
import kotlin.concurrent.thread


@@ 13,6 12,8 @@ class Duet(private val instructions: List<String>, val p: BigInteger = BigIntege
    var partnerQueue = ConcurrentLinkedQueue<BigInteger>()
    private var sendCount = 0

    fun sendCount() = sendCount

    private fun lookupRegister(x: String): BigInteger {
        return registers[x] ?: x.toBigIntegerOrNull() ?: BigInteger.ZERO
    }


@@ 64,7 65,9 @@ class Duet(private val instructions: List<String>, val p: BigInteger = BigIntege
                    return
                }
            }
            val jumpDistance = if (i[0] == "jgz") { jgz(i[1], i[2]) } else 1
            val jumpDistance = if (i[0] == "jgz") {
                jgz(i[1], i[2])
            } else 1
            currentInstruction += jumpDistance
        }
    }


@@ 75,7 78,6 @@ class Duet(private val instructions: List<String>, val p: BigInteger = BigIntege

    private fun send(x: String) {
        sendCount += 1
        println("p: $p, send count: $sendCount")
        partnerQueue.add(lookupRegister(x))
    }



@@ 99,7 101,9 @@ class Duet(private val instructions: List<String>, val p: BigInteger = BigIntege
                "mod" -> mod(i[1], i[2])
                "rcv" -> receive(i[1])
            }
            val jumpDistance = if (i[0] == "jgz") { jgz(i[1], i[2]) } else 1
            val jumpDistance = if (i[0] == "jgz") {
                jgz(i[1], i[2])
            } else 1
            currentInstruction += jumpDistance
        }
    }


@@ 112,22 116,28 @@ fun solve18a(input: List<String>): BigInteger {
    return duet.firstReceived()
}

fun solve18b(input: List<String>) {
fun solve18b(input: List<String>): Int {
    val duet1 = Duet(input, BigInteger.ZERO)
    val duet2 = Duet(input, BigInteger.ONE)

    duet1.partnerQueue = duet2.receivedSounds
    duet2.partnerQueue = duet1.receivedSounds
    thread {
    // TODO: replace with coroutines
    val t1 = thread {
        duet1.duet()
    }
    thread {
    val t2 = thread {
        duet2.duet()
    }
    // wait for deadlock
    Thread.sleep(1000)
    t1.stop()
    t2.stop()
    return duet2.sendCount()
}

fun main() {
    val input = File("src/main/resources/advent2017/day18_input").readText()
//    println(solve18a(input.split("\n")))
    println(solve18b(input.split("\n")))
}
\ No newline at end of file
    val input = input("day18")
    println(solve18a(input)) // 3423
    println(solve18b(input)) // 7493
}

M src/main/advent2017/Day19.kt => src/main/advent2017/Day19.kt +5 -3
@@ 52,6 52,8 @@ fun solve19(input: List<String>): Pair<String, Int> {
}

fun main() {
    val input = File("src/main/resources/advent2017/day19_input").readText()
    println(solve19(input.split("\n")))
}
\ No newline at end of file
    val input = input("day19")
    val (partA, partB) = solve19(input)
    println(partA) // VEBTPXCHLI
    println(partB) // 18702
}

M src/main/advent2017/Day20.kt => src/main/advent2017/Day20.kt +4 -4
@@ 68,7 68,7 @@ fun solve20b(input: List<String>): Int {


fun main() {
    val input = File("src/main/resources/advent2017/day20_input").readText()
//    println(solve20a(input.split("\n")))
    println(solve20b(input.split("\n").filterNot { it == "" }))
}
\ No newline at end of file
    val input = input("day20")
    println(solve20a(input)) // 170
    println(solve20b(input)) // 571
}

M src/main/advent2017/Day21.kt => src/main/advent2017/Day21.kt +13 -4
@@ 89,7 89,7 @@ fun iterateImage(image: List<String>, patterns: Map<List<String>, List<String>>)
    return joinSquaresToImage(splitImageToSquares(image).map { matchPattern(patterns, it) })
}

fun solve21a(input: List<String>, iterations: Int): Int {
fun solve21(input: List<String>, iterations: Int): Int {
    val patterns = mutableMapOf<List<String>, List<String>>()
    input.forEach {
        val (patternIn, patternOut) = it.split(" => ")


@@ 101,7 101,16 @@ fun solve21a(input: List<String>, iterations: Int): Int {
    return finalImage.sumOf { it.count { c -> c == '#' } }
}

fun solve21a(input: List<String>): Int {
    return solve21(input, 5)
}

fun solve21b(input: List<String>): Int {
    return solve21(input, 18)
}

fun main() {
    val input = File("src/main/resources/advent2017/day21_input").readText()
    println(solve21a(input.split("\n").filterNot { it == "" }, 18))
}
\ No newline at end of file
    val input = input("day21")
    println(solve21a(input)) // 205
    println(solve21b(input)) // 3389823
}

M src/main/advent2017/Day22.kt => src/main/advent2017/Day22.kt +4 -4
@@ 114,7 114,7 @@ fun solve22b(input: List<String>, iterations: Int): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day22_input").readText()
//    println(solve22a(input.split("\n").filterNot { it == "" }, 10000))
    println(solve22b(input.split("\n").filterNot { it == "" }, 10_000_000))
}
\ No newline at end of file
    val input = input("day22")
    println(solve22a(input, 10_000)) // 5259
    println(solve22b(input, 10_000_000)) // 2511722
}

M src/main/advent2017/Day23.kt => src/main/advent2017/Day23.kt +5 -7
@@ 1,6 1,5 @@
package advent2017

import java.io.File
import kotlin.math.roundToInt
import kotlin.math.sqrt



@@ 52,7 51,6 @@ class Coprocessor(private val instructions: List<String>, a: Long) {
                jnz(i[1], i[2])
            } else 1
            currentInstruction += jumpDistance
            println(registers)
        }
        return this
    }


@@ 77,8 75,8 @@ fun isPrime(n: Int): Boolean {
}

fun solve23b(input: List<String>): Long {
    Coprocessor(input, 1L).startAt(0).run().getH()
    /*
    Coprocessor(input, 1L).startAt(0).run().getH()
    val hackedRegisters1 = mutableMapOf<String, Long>(
        "a" to 1L,
        "b" to 109300L,


@@ 113,7 111,7 @@ fun solve23b(input: List<String>): Long {
}

fun main() {
    val input = File("src/main/resources/advent2017/day23_input").readText()
    println(solve23a(input.split("\n").filterNot { it == "" }))
    println(solve23b(input.split("\n").filterNot { it == "" }))
}
\ No newline at end of file
    val input = input("day23")
    println(solve23a(input)) // 8281
    println(solve23b(input)) // 911
}

M src/main/advent2017/Day24.kt => src/main/advent2017/Day24.kt +4 -4
@@ 63,7 63,7 @@ fun solve24b(input: List<String>): Int {
}

fun main() {
    val input = File("src/main/resources/advent2017/day24_input").readText()
    println(solve24a(input.split("\n").filterNot { it == "" }))
    println(solve24b(input.split("\n").filterNot { it == "" }))
}
\ No newline at end of file
    val input = input("day24")
    println(solve24a(input)) // 1859
    println(solve24b(input)) // 1799
}

M src/main/advent2017/Day25.kt => src/main/advent2017/Day25.kt +1 -1
@@ 85,5 85,5 @@ fun solve25a(): Int {
}

fun main() {
    println(solve25a())
    println(solve25a()) // 4287
}

A src/main/advent2017/Input.kt => src/main/advent2017/Input.kt +5 -0
@@ 0,0 1,5 @@
package advent2017

const val adventYear = "advent2017"

fun input(day: String) = common.input(adventYear, day)

M src/main/advent2018/Input.kt => src/main/advent2018/Input.kt +2 -5
@@ 1,8 1,5 @@
package advent2018

import java.io.File
const val adventYear = "advent2018"

fun input(dayNumber: String): List<String> {
    val filename = dayNumber + "_input.txt"
    return File("src/main/resources/advent2018/${filename}").readLines()
}
\ No newline at end of file
fun input(day: String) = common.input(adventYear, day)

M src/main/advent2019/Input.kt => src/main/advent2019/Input.kt +2 -5
@@ 1,8 1,5 @@
package advent2019

import java.io.File
const val adventYear = "advent2019"

fun input(dayNumber: String): List<String> {
    val filename = dayNumber + "_input.txt"
    return File("src/main/resources/advent2019/${filename}").readLines()
}
\ No newline at end of file
fun input(day: String) = common.input(adventYear, day)

M src/main/advent2019/Intcode.kt => src/main/advent2019/Intcode.kt +0 -1
@@ 1,6 1,5 @@
package advent2019

import common.chunkWhen
import java.util.*

typealias Intcode = List<Long>

M src/main/advent2020/Day04.kt => src/main/advent2020/Day04.kt +3 -3
@@ 68,7 68,7 @@ fun solve4b(inputText: String): Int {
}

fun main() {
    val input = inputText("day04")
    println(solve4a(input)) // 233
    println(solve4b(input)) // 111
    val inputText = inputText("day04")
    println(solve4a(inputText)) // 233
    println(solve4b(inputText)) // 111
}

M src/main/advent2020/Day16.kt => src/main/advent2020/Day16.kt +3 -3
@@ 59,7 59,7 @@ fun solve16b(input: String): Long {
}

fun main() {
    val input = inputText("day16").trim()
    println(solve16a(input)) // 28873
    println(solve16b(input)) // 2587271823407
    val inputText = inputText("day16")
    println(solve16a(inputText)) // 28873
    println(solve16b(inputText)) // 2587271823407
}

M src/main/advent2020/Day19.kt => src/main/advent2020/Day19.kt +1 -1
@@ 63,6 63,6 @@ fun solve19b(input: String): Int {
fun main() {
    val inputText = inputText("day19")
    println(solve19a(inputText)) // 139
    println(solve19b(inputText))
    println(solve19b(inputText)) // 289
}


M src/main/advent2020/Input.kt => src/main/advent2020/Input.kt +3 -10
@@ 1,13 1,6 @@
package advent2020

import java.io.File
const val adventYear = "advent2020"

fun input(prefix: String): List<String> {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/advent2020/${filename}").readLines()
}

fun inputText(prefix: String): String {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/advent2020/${filename}").readText()
}
fun input(day: String) = common.input(adventYear, day)
fun inputText(day: String) = common.inputText(adventYear, day)

M src/main/advent2021/Input.kt => src/main/advent2021/Input.kt +2 -10
@@ 1,13 1,5 @@
package advent2021

import java.io.File
const val adventYear = "advent2021"

fun input(prefix: String): List<String> {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/advent2021/${filename}").readLines()
}

fun inputText(prefix: String): String {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/advent2021/${filename}").readText()
}
\ No newline at end of file
fun input(day: String) = common.input(adventYear, day)

A src/main/advent2022/Input.kt => src/main/advent2022/Input.kt +6 -0
@@ 0,0 1,6 @@
package advent2022

const val adventYear = "advent2022"

fun input(day: String) = common.input(adventYear, day)
fun inputText(day: String) = common.input(adventYear, day)

A src/main/common/Input.kt => src/main/common/Input.kt +13 -0
@@ 0,0 1,13 @@
package common

import java.io.File

fun input(adventYear: String, prefix: String): List<String> {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/${adventYear}/${filename}").readLines()
}

fun inputText(adventYear: String, prefix: String): String {
    val filename = prefix + "_input.txt"
    return File("src/main/resources/${adventYear}/${filename}").readText()
}

A src/main/resources/advent2017/day01_input.txt => src/main/resources/advent2017/day01_input.txt +1 -0
@@ 0,0 1,1 @@
31813174349235972159811869755166343882958376474278437681632495222499211488649543755655138842553867246131245462881756862736922925752647341673342756514856663979496747158241792857625471323535183222497949751644488277317173496124473893452425118133645984488759128897146498831373795721661696492622276282881218371273973538163779782435211491196616375135472517935481964439956844536136823757764494967297251545389464472794474447941564778733926532741752757865243946976266426548341889873514383464142659425122786667399143335772174973128383869893325977319651839516694295534146668728822393452626321892357192574444856264721585365164945647254645264693957898373214897848424966266582991272496771159583715456714645585576641458358326521858518319315233857473695712238323787254556597566461188452279853766184333696344395818615215846348586541164194624371353556812548945447432787795489443312941687221314432694115847863129826532628228386894683392352799514942665396273726821936346663485499159141368443782475714679953213388375939519711591262489869326145476958378464652451441434846382474578535468433514121336844727988128998543975147649823215332929623574231738442281161294838499441799996857746549441142859199799125595761724782225452394593514388571187279266291364278184761833324476838939898258225748562345853633364314923186685534864178665214135631494876474186833392929124337161222959459117554238429216916532175247326391321525832362274683763488347654497889261543959591212539851835354335598844669618391876623638137926893582131945361264841733341247646125278489995838369127582438419889922365596554237153412394494932582424222479798382932335239274297663365164912953364777876187522324991837775492621675953397843833247525599771974555545348388871578347332456586949283657613841414576976542343934911424716613479249893113961925713317644349946444271959375981158445151659431844142242547191181944395897963146947935463718145169266129118413523541222444997678726644615185324461293228124456118853885552279849917342474792984425629248492847827653133583215539325866881662159421987315186914769478947389188382383546881622246793781846254253759714573354544997853153798862436887889318646643359555663135476261863

A src/main/resources/advent2017/day02_input.txt => src/main/resources/advent2017/day02_input.txt +16 -0
@@ 0,0 1,16 @@
4168	3925	858	2203	440	185	2886	160	1811	4272	4333	2180	174	157	361	1555
150	111	188	130	98	673	408	632	771	585	191	92	622	158	537	142
5785	5174	1304	3369	3891	131	141	5781	5543	4919	478	6585	116	520	673	112
5900	173	5711	236	2920	177	3585	4735	2135	2122	5209	265	5889	233	4639	5572
861	511	907	138	981	168	889	986	980	471	107	130	596	744	251	123
2196	188	1245	145	1669	2444	656	234	1852	610	503	2180	551	2241	643	175
2051	1518	1744	233	2155	139	658	159	1178	821	167	546	126	974	136	1946
161	1438	3317	4996	4336	2170	130	4987	3323	178	174	4830	3737	4611	2655	2743
3990	190	192	1630	1623	203	1139	2207	3994	1693	1468	1829	164	4391	3867	3036
116	1668	1778	69	99	761	201	2013	837	1225	419	120	1920	1950	121	1831
107	1006	92	807	1880	1420	36	1819	1039	1987	114	2028	1771	25	85	430
5295	1204	242	479	273	2868	3453	6095	5324	6047	5143	293	3288	3037	184	987
295	1988	197	2120	199	1856	181	232	564	1914	1691	210	1527	1731	1575	31
191	53	714	745	89	899	854	679	45	81	726	801	72	338	95	417
219	3933	6626	2137	3222	1637	5312	238	5895	222	154	6649	169	6438	3435	4183
37	1069	166	1037	172	258	1071	90	497	1219	145	1206	143	153	1067	510

A src/main/resources/advent2017/day03_input.txt => src/main/resources/advent2017/day03_input.txt +1 -0
@@ 0,0 1,1 @@
277678

R src/main/resources/advent2017/day4_input => src/main/resources/advent2017/day04_input.txt +0 -0
R src/main/resources/advent2017/day5_input => src/main/resources/advent2017/day05_input.txt +0 -0
A src/main/resources/advent2017/day06_input.txt => src/main/resources/advent2017/day06_input.txt +1 -0
@@ 0,0 1,1 @@
4	1	15	12	0	9	9	5	5	8	7	3	14	5	12	3

R src/main/resources/advent2017/day7_input => src/main/resources/advent2017/day07_input.txt +0 -0
R src/main/resources/advent2017/day8_input => src/main/resources/advent2017/day08_input.txt +0 -0
R src/main/resources/advent2017/day9_input => src/main/resources/advent2017/day09_input.txt +0 -0
A src/main/resources/advent2017/day10_input.txt => src/main/resources/advent2017/day10_input.txt +1 -0
@@ 0,0 1,1 @@
192,69,168,160,78,1,166,28,0,83,198,2,254,255,41,12

R src/main/resources/advent2017/day11_input => src/main/resources/advent2017/day11_input.txt +0 -0
R src/main/resources/advent2017/day12_input => src/main/resources/advent2017/day12_input.txt +0 -0
R src/main/resources/advent2017/day13_input => src/main/resources/advent2017/day13_input.txt +0 -0
A src/main/resources/advent2017/day14_input.txt => src/main/resources/advent2017/day14_input.txt +1 -0
@@ 0,0 1,1 @@
oundnydw

R src/main/resources/advent2017/day15_input => src/main/resources/advent2017/day15_input.txt +0 -0
R src/main/resources/advent2017/day16_input => src/main/resources/advent2017/day16_input.txt +0 -0
A src/main/resources/advent2017/day17_input.txt => src/main/resources/advent2017/day17_input.txt +1 -0
@@ 0,0 1,1 @@
328

R src/main/resources/advent2017/day18_input => src/main/resources/advent2017/day18_input.txt +0 -0
R src/main/resources/advent2017/day19_input => src/main/resources/advent2017/day19_input.txt +0 -0
R src/main/resources/advent2017/day20_input => src/main/resources/advent2017/day20_input.txt +0 -0
A src/main/resources/advent2017/day21_input.txt => src/main/resources/advent2017/day21_input.txt +108 -0
@@ 0,0 1,108 @@
../.. => ###/.##/#..
#./.. => #.#/..#/#..
##/.. => ###/.#./###
.#/#. => ##./###/...
##/#. => ##./###/#.#
##/## => #.#/#.#/###
.../.../... => #.#./#..#/#.##/#.#.
#../.../... => #.##/.##./#..#/.###
.#./.../... => #..#/#.#./.#../#.##
##./.../... => .#../...#/####/...#
#.#/.../... => ##.#/..#./...#/###.
###/.../... => #.#./#..#/####/##..
.#./#../... => ..##/..##/####/##.#
##./#../... => #.#./#.../..../##..
..#/#../... => .#.#/##.#/...#/####
#.#/#../... => .#../.###/.##./##.#
.##/#../... => ##../.#.#/#.../..##
###/#../... => ##.#/##.#/.###/##..
.../.#./... => ..#./..../##.#/#.#.
#../.#./... => ..##/.#.#/..#./###.
.#./.#./... => ...#/.#../.#.#/##..
##./.#./... => #..#/.###/##../#.#.
#.#/.#./... => ##.#/..#./.#../#..#
###/.#./... => #.#./####/#..#/#...
.#./##./... => ##../##.#/.###/##..
##./##./... => .#../####/.##./.#..
..#/##./... => ####/##.#/##.#/###.
#.#/##./... => .##./#.##/##.#/#...
.##/##./... => ..../#.##/##.#/##..
###/##./... => #.../.##./#.#./#...
.../#.#/... => #..#/..##/#.../#.##
#../#.#/... => ..##/..#./..#./..##
.#./#.#/... => ..##/####/####/....
##./#.#/... => ###./.#../##.#/#.#.
#.#/#.#/... => .##./#..#/..#./##..
###/#.#/... => ##.#/..#./#..#/...#
.../###/... => ..##/.#.#/#.../...#
#../###/... => ..##/#.##/#.#./..#.
.#./###/... => ##../..##/.##./...#
##./###/... => #.#./#.../#.../.##.
#.#/###/... => ##.#/..##/..##/.###
###/###/... => ..#./#..#/.#../.##.
..#/.../#.. => ###./#.#./#.##/#.##
#.#/.../#.. => ####/.##./#..#/.###
.##/.../#.. => #.#./..../..../##.#
###/.../#.. => .#.#/..../.#.#/###.
.##/#../#.. => ####/#..#/.##./####
###/#../#.. => ##../.#../..../###.
..#/.#./#.. => .###/##../#.##/...#
#.#/.#./#.. => ...#/####/#.../..#.
.##/.#./#.. => #.../####/.#.#/###.
###/.#./#.. => ####/..../.#../##..
.##/##./#.. => ..../###./##../.###
###/##./#.. => #.../#..#/#..#/###.
#../..#/#.. => ..../.###/.#../.#.#
.#./..#/#.. => .#.#/...#/#.#./##..
##./..#/#.. => .#../##.#/.#../.##.
#.#/..#/#.. => ##../#.##/.###/#.#.
.##/..#/#.. => #.#./..../.#.#/..##
###/..#/#.. => ...#/#.../...#/..#.
#../#.#/#.. => ##.#/..#./###./.###
.#./#.#/#.. => ..../##../.#.#/.###
##./#.#/#.. => ###./#.#./.#../.#.#
..#/#.#/#.. => ###./..../##.#/#..#
#.#/#.#/#.. => .#.#/#.##/#.../..#.
.##/#.#/#.. => .#.#/#.../##../####
###/#.#/#.. => #.##/..#./..##/....
#../.##/#.. => .#../.#../...#/#...
.#./.##/#.. => ##../#..#/###./##.#
##./.##/#.. => .#.#/#..#/..../#..#
#.#/.##/#.. => ##.#/..../##../##..
.##/.##/#.. => #.#./..#./#.../.#..
###/.##/#.. => #.#./##.#/####/....
#../###/#.. => ##../#.##/.#../.###
.#./###/#.. => #.../#.##/..../.#.#
##./###/#.. => ###./##../.#../..##
..#/###/#.. => ..#./.#../####/#..#
#.#/###/#.. => #.##/..#./..#./#.##
.##/###/#.. => .#../#.../####/#...
###/###/#.. => #.../..#./..../.##.
.#./#.#/.#. => .#.#/####/###./....
##./#.#/.#. => ##.#/###./#.##/#..#
#.#/#.#/.#. => ####/#.#./..../##..
###/#.#/.#. => ##.#/##../.###/..##
.#./###/.#. => .##./...#/##.#/.###
##./###/.#. => ..##/.#../..#./#...
#.#/###/.#. => ####/#.../..#./#.#.
###/###/.#. => #.../.###/..##/.#.#
#.#/..#/##. => ...#/###./#.#./#.##
###/..#/##. => ##../..#./###./##..
.##/#.#/##. => #.../#.#./#.#./#..#
###/#.#/##. => #.../##.#/#.#./....
#.#/.##/##. => ...#/#.#./...#/#...
###/.##/##. => .###/...#/#..#/###.
.##/###/##. => ###./.##./##.#/#..#
###/###/##. => #.../##../.###/.#..
#.#/.../#.# => #.../#..#/...#/#..#
###/.../#.# => .#../..##/.##./.#.#
###/#../#.# => ..../.#.#/###./#...
#.#/.#./#.# => ##.#/.#.#/#.##/...#
###/.#./#.# => ..../#.../#.../.###
###/##./#.# => ..##/.##./##.#/##.#
#.#/#.#/#.# => ..##/.#../..##/..#.
###/#.#/#.# => ..##/.###/...#/##..
#.#/###/#.# => ..#./.#.#/.###/####
###/###/#.# => #.#./##../#.#./##.#
###/#.#/### => #.#./..##/#.#./#...
###/###/### => ##../.###/###./#..#

R src/main/resources/advent2017/day22_input => src/main/resources/advent2017/day22_input.txt +0 -0
R src/main/resources/advent2017/day23_input => src/main/resources/advent2017/day23_input.txt +0 -0
R src/main/resources/advent2017/day24_input => src/main/resources/advent2017/day24_input.txt +0 -0
M src/test/advent2017/Day12KtTest.kt => src/test/advent2017/Day12KtTest.kt +2 -2
@@ 4,7 4,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

internal class Day12KtTest {
    val s = "0 <-> 2\n1 <-> 1\n2 <-> 0, 3, 4\n3 <-> 2, 4\n4 <-> 2, 3, 6\n5 <-> 6\n6 <-> 4, 5"
    val s = "0 <-> 2\n1 <-> 1\n2 <-> 0, 3, 4\n3 <-> 2, 4\n4 <-> 2, 3, 6\n5 <-> 6\n6 <-> 4, 5".split("\n")

    @Test
    fun solve12a() {


@@ 15,4 15,4 @@ internal class Day12KtTest {
    fun solve12b() {
        assertEquals(2, solve12b(s))
    }
}
\ No newline at end of file
}

M src/test/advent2017/Day21KtTest.kt => src/test/advent2017/Day21KtTest.kt +2 -2
@@ 12,6 12,6 @@ internal class Day21KtTest {

    @Test
    fun solve21a() {
        assertEquals(12, solve21a(listOf("../.# => ##./#../...", ".#./..#/### => #..#/..../..../#..#"), 2))
        assertEquals(12, solve21(listOf("../.# => ##./#../...", ".#./..#/### => #..#/..../..../#..#"), 2))
    }
}
\ No newline at end of file
}