From e5d0761834bb4cb7ce86d5fbf48f335274efd18b Mon Sep 17 00:00:00 2001 From: gergo Date: Fri, 9 Dec 2022 22:53:41 +0100 Subject: [PATCH] day 9 --- src/main/kotlin/me/gergo/Aoc09.kt | 87 ++ src/main/resources/input09.txt | 2000 +++++++++++++++++++++++++++++ 2 files changed, 2087 insertions(+) create mode 100644 src/main/kotlin/me/gergo/Aoc09.kt create mode 100644 src/main/resources/input09.txt diff --git a/src/main/kotlin/me/gergo/Aoc09.kt b/src/main/kotlin/me/gergo/Aoc09.kt new file mode 100644 index 0000000..18fab08 --- /dev/null +++ b/src/main/kotlin/me/gergo/Aoc09.kt @@ -0,0 +1,87 @@ +package me.gergo + +import java.io.File +import java.lang.Integer.max +import kotlin.math.abs +import kotlin.math.sign + +fun main() { + val steps = File("src/main/resources/input09.txt").readLines() + .map(::parseRopeStep) + + // val ropeField = RopeField(6, 5, 2) // For Part One + val ropeField = RopeField(6, 5, 10) // For Part Two + for (step in steps) { + println(step) + ropeField.moveBy(step) + } + println("Positions visited by tail: ${ropeField.positionsVisitedByTail().count()}") +} + +enum class Direction { L, R, U, D } +data class RopeStep(val dir: Direction, val steps: Int) +data class Position(val x: Int, val y: Int) { + fun distanceFrom(o: Position) = max(abs(x - o.x), abs(y - o.y)) +} + +class Rope(internal val knots: MutableList) { + + fun head() = knots[0] + fun tail() = knots[knots.size - 1] + + internal fun moveHead(dir: Direction) { + val head = head() + knots[0] = when (dir) { + Direction.L -> Position(head.x - 1, head.y) + Direction.R -> Position(head.x + 1, head.y) + Direction.U -> Position(head.x, head.y + 1) + Direction.D -> Position(head.x, head.y - 1) + } + for (i in 1 until knots.size) { + val prev = knots[i - 1] + var curr = knots[i] + while (prev.distanceFrom(curr) > 1) { + val fx = (prev.x - curr.x).sign + val fy = (prev.y - curr.y).sign + curr = if (fx == 0) { + Position(curr.x, curr.y + fy) + } else if (fy == 0) { + Position(curr.x + fx, curr.y) + } else { + Position(curr.x + fx, curr.y + fy) + } + } + knots[i] = curr + } + } +} + +class RopeField(private val width: Int, private val height: Int, ropeLength: Int) { + private val rope = Rope(MutableList(ropeLength) { Position(0, 0) }) + private val tailPositions = mutableListOf() + + fun moveBy(step: RopeStep) { + for (s in 1..step.steps) { + rope.moveHead(step.dir) + tailPositions.add(rope.tail()) + // println(this) // For simple debugging, does not work for negative coordinates! + } + } + + override fun toString(): String { + val buf = Array(height) { CharArray(width) { '.' } } + for (i in 1 until rope.knots.size) { + val knot = rope.knots[i] + buf[height - 1 - knot.y][knot.x] = i.digitToChar() + } + buf[height - 1 - rope.head().y][rope.head().x] = 'H' + return buf.joinToString("\n") { it.joinToString("") } + '\n' + } + + fun positionsVisitedByTail() = tailPositions.toSet() +} + +fun parseRopeStep(line: String): RopeStep { + val (dir, steps) = line.split(" ") + return RopeStep(Direction.valueOf(dir), steps.toInt()) +} diff --git a/src/main/resources/input09.txt b/src/main/resources/input09.txt new file mode 100644 index 0000000..7723afa --- /dev/null +++ b/src/main/resources/input09.txt @@ -0,0 +1,2000 @@ +R 1 +D 1 +L 2 +R 1 +U 2 +R 2 +L 1 +R 2 +L 2 +D 1 +L 2 +D 2 +U 2 +D 1 +U 1 +D 1 +R 2 +D 2 +R 1 +L 2 +R 1 +U 1 +D 1 +U 2 +L 1 +D 2 +R 2 +D 2 +R 1 +L 1 +D 1 +R 1 +D 2 +L 2 +U 1 +D 1 +R 1 +L 2 +R 2 +L 1 +U 1 +D 1 +U 1 +D 1 +R 2 +L 1 +D 2 +L 2 +R 1 +L 2 +R 2 +U 2 +R 2 +D 1 +U 2 +L 1 +D 1 +R 1 +L 1 +U 1 +D 1 +L 2 +U 2 +D 2 +L 1 +R 1 +L 2 +D 1 +R 1 +D 1 +U 2 +L 2 +R 2 +L 1 +D 2 +L 1 +R 2 +D 2 +U 1 +R 1 +L 2 +D 1 +L 1 +U 2 +R 1 +U 2 +L 2 +U 1 +D 2 +L 2 +R 2 +D 2 +L 2 +U 1 +L 2 +U 1 +D 1 +U 2 +R 1 +U 2 +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16 +R 15 +D 16 +R 4 +L 15 +R 15 +D 7 +L 17 +U 11 +D 7 +L 10 +U 9 +R 8 +L 12 +U 16 +D 9 +R 17 +D 5 +U 3 +L 12 +D 11 +R 1 +D 8 +L 8 +U 14 +L 11 +U 2 +R 13 +L 15 +D 6 +L 1 +U 14 +L 14 +R 15 +L 10 +U 10 +D 16 +R 17 +L 3 +D 6 +U 13 +D 8 +U 2 +L 8 +R 7 +L 3 +D 13 +L 18 +U 7 +L 1 +D 5 +U 7 +D 18 +U 7 +D 2 +R 10 +D 8 +U 10 +R 10 +L 17 +R 17 +L 14 +R 17 +U 9 +L 6 +U 14 +L 3 +D 7 +L 13 +D 11 +U 13 +R 17 +L 11 +R 17 +D 12 +L 9 +U 18 +D 10 +U 2 +L 11 +D 12 +U 1 +L 15 +D 17 +U 6 +L 5 +R 7 +D 18 +R 17 +L 10 +R 10 +D 2 +R 3 +L 13 +D 7 +R 12 +U 6 +D 16 +L 4 +R 2 +L 3 +U 10 +D 6 +U 13 +L 2 +D 15 +L 13 +U 10 +L 16 +D 9 +L 10 +R 12 +U 11 +D 3 +L 12 +D 14 +R 7 +L 10 +R 1 +U 15 +L 10 +D 9 +U 17 +R 16 +L 8 +D 3 +L 3 +R 6 +U 4 +R 4 +D 11 +R 7 +L 4 +U 4 +D 6 +L 7 +U 17 +R 10 +L 7 +D 4 +U 2 +L 8 +D 3 +U 11 +L 5 +R 1 +U 13 +D 3 +L 14 +D 8 +R 6 +D 6 +L 4 +U 16 +L 12 +R 18 +U 18 +L 13 +D 15 +U 17 +L 6 +U 12 +L 14 +R 13 +D 11 +R 14 +U 13 +L 3 +U 13 +D 19 +R 6 +L 12 +D 2 +L 4 +R 8 +L 17 +R 14 +L 1 +D 14 +L 3 +U 19 +L 19 +U 6 +L 14 +D 3 +R 8 +L 10 +R 13 +D 7 +U 9 +R 5 +U 15 +L 18 +R 9 +U 19 +D 10 +U 9 +R 17 +U 11 +R 6 +D 16 +L 6 +R 15 +U 5 +D 3 +R 1 +U 9 +L 10 +R 5 +L 7 +D 16 +U 16 +R 16 +D 12 +R 15 +D 15 +L 15 +D 3 +U 15 +D 11 +U 15 +D 12 +L 18 +U 11 +R 16 +D 5 +R 7 +D 6 +U 18 +R 8 +D 6 +U 10 +R 18 +D 10 +L 5 +U 14 +R 8 +U 14 +L 14 +R 12 +L 1 +D 8 +U 5 +D 12 +L 9 +R 15 +D 16 +L 17 +D 17 +L 16 +U 17 +L 14 +D 11 +R 13 +L 8 +D 1 +L 18 +U 3 +R 14 +D 17 +U 17 +R 19