Skip to content

Commit

Permalink
Add AOC2024 day 25, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
FWDekker committed Dec 27, 2024
1 parent d372b8e commit 3b2b8d7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 37 deletions.
34 changes: 34 additions & 0 deletions aoc/src/main/kotlin/com/fwdekker/aoc/y2024/Day25.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.fwdekker.aoc.y2024

import com.fwdekker.aoc.Day
import com.fwdekker.std.collections.seconds
import com.fwdekker.std.grid.Chart
import com.fwdekker.std.grid.col
import com.fwdekker.std.grid.cols
import com.fwdekker.std.grid.firstRow
import com.fwdekker.std.sections


// See https://adventofcode.com/2024/day/25
class Day25(sample: Int? = null) : Day(year = 2024, day = 25, sample = sample) {
private val sections = input.sections()
private val height = sections.first().size

private val products = sections
.map { product -> product.map { it.toList() } }
.map { product -> product.firstRow.all { it == '#' } to product.toHeights() }
private val locks = products.filter { it.first }.seconds()
private val keys = products.filter { !it.first }.seconds()


override fun part1() =
locks.sumOf { lock -> keys.count { key -> lock.zip(key) { a, b -> a + b }.all { it <= height } } }

override fun part2() = 0


private fun Chart.toHeights(): List<Int> = cols.map { col -> col(col).count { it == '#' } }
}


fun main() = Day25().run()
17 changes: 0 additions & 17 deletions aoc/src/main/kotlin/com/fwdekker/aoc/y2024/Day999.kt

This file was deleted.

2 changes: 1 addition & 1 deletion aoc/src/main/resources
16 changes: 16 additions & 0 deletions aoc/src/test/kotlin/com/fwdekker/aoc/y2024/Day25Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.fwdekker.aoc.y2024

import com.fwdekker.std.ChallengeTest
import io.kotest.core.annotation.Tags


@Tags("2024")
object Day25Test : ChallengeTest(
::Day25,
listOf(
case(part = 1, sample = 1) to 3,
// case(part = 2, sample = 1) to TODO(),
case(part = 1) to 3344,
// case(part = 2) to TODO(),
)
)
19 changes: 0 additions & 19 deletions aoc/src/test/kotlin/com/fwdekker/aoc/y2024/Day999Test.kt

This file was deleted.

0 comments on commit 3b2b8d7

Please sign in to comment.