Day 20 (WIP)

This commit is contained in:
2018-12-20 23:23:39 +01:00
parent 0b28df1f3c
commit 14e7ca488e
4 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
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)
}
}
}
}

View File

@@ -0,0 +1 @@
^ESSWWN(E|NNENN(EESS(WNSE|)SSS|WWWSSSSE(SW|NNNE)))$

View File

@@ -0,0 +1 @@
^WSSEESWWWNW(S|NENNEEEENN(ESSSSW(NWSW|SSEN)|WSWWN(E|WWS(E|SS))))$

File diff suppressed because one or more lines are too long