53 lines
1.1 KiB
Kotlin
53 lines
1.1 KiB
Kotlin
package com.basdado.adventofcode
|
|
|
|
import java.util.*
|
|
|
|
const val DAY20_INPUT = "/day/20/example1.txt"
|
|
|
|
fun main() {
|
|
|
|
val day = Day20()
|
|
day.puzzle1()
|
|
}
|
|
|
|
class Day20 {
|
|
|
|
fun puzzle1() {
|
|
|
|
val input = lines(DAY20_INPUT).findFirst().get()
|
|
]
|
|
val rooms = mutableListOf(Room(Vector2(0, 0), mutableListOf()))
|
|
val bracketStarts = Stack<Room>()
|
|
var currentRoom = rooms[0]
|
|
|
|
for(c in input) {
|
|
if (c == '^') {
|
|
continue
|
|
}
|
|
|
|
if (c == '(') {
|
|
bracketStarts.push(currentRoom)
|
|
}
|
|
|
|
if (c == '|') {
|
|
currentRoom = bracketStarts.pop()
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class Room(val pos: Vector2, val connections: MutableList<Room>)
|
|
|
|
data class Vector2(val x: Long, val y: Long) {
|
|
fun move(c: Char): Vector2 {
|
|
return when(c) {
|
|
'N' -> Vector2(x, y - 1)
|
|
'E' -> Vector2(x + 1, y)
|
|
'S' -> Vector2(x, y + 1)
|
|
'W' -> Vector2(x - 1, y)
|
|
|
|
}
|
|
}
|
|
}
|
|
} |