Skip to content

Commit

Permalink
2024 - Day 16 - parse
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmr committed Dec 16, 2024
1 parent 5f4585f commit d340ddf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/no/rodland/advent/Cave.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ fun fromMap(map: Map<Pos, Char>): Cave {
}
}

fun List<String>.toCave(): Cave = map { line -> line.toCharArray() }.toTypedArray()

@Suppress("UNUSED_PARAMETER")
fun Cave.print(minX: Int = 0, minY: Int = 0, maxX: Int = first().size, maxY: Int = size) {
forEach { ca ->
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/no/rodland/advent_2024/Day16.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package no.rodland.advent_2024

import no.rodland.advent.Cave
import no.rodland.advent.Day
import no.rodland.advent.toCave

// template generated: 15/12/2024
// Fredrik Rødland 2024

class Day16(val input: List<String>) : Day<Long, Long, List<String>> {
class Day16(val input: List<String>) : Day<Long, Long, Array<CharArray>> {

private val parsed = input.parse()
private val maze = input.parse()

override fun partOne(): Long {
return 2
Expand All @@ -17,10 +19,8 @@ class Day16(val input: List<String>) : Day<Long, Long, List<String>> {
return 2
}

override fun List<String>.parse(): List<String> {
return map { line ->
line
}
override fun List<String>.parse(): Cave {
return this.toCave()
}

override val day = "16".toInt()
Expand Down
15 changes: 15 additions & 0 deletions src/test/resources/2024/input_16_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
###############
#.......#....E#
#.#.###.#.###.#
#.....#.#...#.#
#.###.#####.#.#
#.#.#.......#.#
#.#.#####.###.#
#...........#.#
###.#.#####.#.#
#...#.....#.#.#
#.#.#.###.#.#.#
#.....#...#.#.#
#.###.#.#.#.#.#
#S..#.....#...#
###############

0 comments on commit d340ddf

Please sign in to comment.