diff --git a/README.md b/README.md index 41bf9b6c..89632ba8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To run all solutions, simply run `./gradlew run`. If you want to run the solutio ## Contributions: | Year | Language(s) | Total Stars | Link to repository | |---------|--------------------------------------------------------------|------------:|------------------------------------------------------------------------------------| -| 2024 | Kotlin ![Kotlin](img/kotlin.png) | 6 / 50 ⭐ | [aoc2024](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2024) | +| 2024 | Kotlin ![Kotlin](img/kotlin.png) | 8 / 50 ⭐ | [aoc2024](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2024) | | 2023 | Java ![Java](img/java.png), Kotlin ![Kotlin](img/kotlin.png) | 50 / 50 ⭐ | [aoc2023](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2023) | | 2022 | Java ![Java](img/java.png), Kotlin ![Kotlin](img/kotlin.png) | 50 / 50 ⭐ | [aoc2022](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2022) | | 2022 | Kotlin ![Kotlin](img/kotlin.png) | 2 / 2 ⭐ | [meilisearch](https://github.com/Gentleman1983/advent-of-code/tree/main/meili2022) | @@ -28,5 +28,5 @@ To run all solutions, simply run `./gradlew run`. If you want to run the solutio | 2017 | Java ![Java](img/java.png), Kotlin ![Kotlin](img/kotlin.png) | 50 / 50 ⭐ | [aoc2017](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2017) | | 2016 | Java ![Java](img/java.png), Kotlin ![Kotlin](img/kotlin.png) | 50 / 50 ⭐ | [aoc2016](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2016) | | 2015 | Java ![Java](img/java.png), Kotlin ![Kotlin](img/kotlin.png) | 50 / 50 ⭐ | [aoc2015](https://github.com/Gentleman1983/advent-of-code/tree/main/aoc2015) | -| **SUM** | | **458 ⭐** | | +| **SUM** | | **460 ⭐** | | diff --git a/aoc2024/README.md b/aoc2024/README.md index 10856901..9b151917 100644 --- a/aoc2024/README.md +++ b/aoc2024/README.md @@ -13,7 +13,7 @@ For more information see https://adventofcode.com [2024](https://adventofcode.co | 1 | ⭐ ![Kotlin](../img/kotlin.png) | ⭐ ![Kotlin](../img/kotlin.png) | | 2 | ⭐ ![Kotlin](../img/kotlin.png) | ⭐ ![Kotlin](../img/kotlin.png) | | 3 | ⭐ ![Kotlin](../img/kotlin.png) | ⭐ ![Kotlin](../img/kotlin.png) | -| 4 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | +| 4 | ⭐ ![Kotlin](../img/kotlin.png) | ⭐ ![Kotlin](../img/kotlin.png) | | 5 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | | 6 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | | 7 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | @@ -35,9 +35,9 @@ For more information see https://adventofcode.com [2024](https://adventofcode.co | 23 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | | 24 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | | 25 | ❌ ![Kotlin](../img/kotlin.png) | ❌ ![Kotlin](../img/kotlin.png) | -| **SUM** | **3 ⭐** | **3 ⭐** | +| **SUM** | **4 ⭐** | **4 ⭐** | -Total: 6 ⭐ +Total: 8 ⭐ ## Solution image N/A diff --git a/aoc2024/aoc2024-kotlin/src/main/kotlin/de/havox_design/aoc2024/day04/CeresSearch.kt b/aoc2024/aoc2024-kotlin/src/main/kotlin/de/havox_design/aoc2024/day04/CeresSearch.kt index ad5381c6..2bfc1076 100644 --- a/aoc2024/aoc2024-kotlin/src/main/kotlin/de/havox_design/aoc2024/day04/CeresSearch.kt +++ b/aoc2024/aoc2024-kotlin/src/main/kotlin/de/havox_design/aoc2024/day04/CeresSearch.kt @@ -25,7 +25,23 @@ class CeresSearch(private var filename: String) { } fun processPart2(): Any = - 0L + data + .indices + .sumOf { y -> + data[y] + .indices + .count { x -> + if (data[y][x] != 'A') { + return@count false + } + + val n = data.getOrNull(y - 1) ?: return@count false + val s = data.getOrNull(y + 1) ?: return@count false + + setOf(n.getOrNull(x - 1), s.getOrNull(x + 1)) == MS && + setOf(n.getOrNull(x + 1), s.getOrNull(x - 1)) == MS + } + } private fun getResourceAsText(path: String): List = this @@ -37,5 +53,6 @@ class CeresSearch(private var filename: String) { companion object { private const val XMAS = "XMAS" + private val MS = setOf('M', 'S') } } diff --git a/aoc2024/aoc2024-kotlin/src/test/kotlin/de/havox_design/aoc2024/day04/CeresSearchTest.kt b/aoc2024/aoc2024-kotlin/src/test/kotlin/de/havox_design/aoc2024/day04/CeresSearchTest.kt index aaa88ad1..02ad49ac 100644 --- a/aoc2024/aoc2024-kotlin/src/test/kotlin/de/havox_design/aoc2024/day04/CeresSearchTest.kt +++ b/aoc2024/aoc2024-kotlin/src/test/kotlin/de/havox_design/aoc2024/day04/CeresSearchTest.kt @@ -28,7 +28,7 @@ class CeresSearchTest { @JvmStatic private fun getDataForTestProcessPart2(): Stream = Stream.of( - Arguments.of("de/havox_design/aoc2024/day04/day04part2sample.txt", 9) + Arguments.of("de/havox_design/aoc2024/day04/day04sample.txt", 9) ) } }