-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
Submodule resources
updated
from 2501c6 to 6cbd76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
) | ||
) |
This file was deleted.
Oops, something went wrong.