-
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
3 changed files
with
146 additions
and
0 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,36 @@ | ||
package no.rodland.advent_2024 | ||
|
||
import no.rodland.advent.Day | ||
|
||
// template generated: 05/12/2024 | ||
// Fredrik Rødland 2024 | ||
|
||
class Day05(val input: List<String>) : Day<Long, Long, Pair<List<Pair<Int, Int>>, List<List<Int>>>> { | ||
|
||
private val parsed = input.parse() | ||
private val rules = parsed.first | ||
private val pages = parsed.second | ||
|
||
override fun partOne(): Long { | ||
return 2 | ||
} | ||
|
||
override fun partTwo(): Long { | ||
return 2 | ||
} | ||
|
||
override fun List<String>.parse(): Pair<List<Pair<Int, Int>>, List<List<Int>>> { | ||
val (rulesStr, pagesStr) = this.joinToString("\n").split("\n\n").map { it.split("\n") } | ||
|
||
val pages = pagesStr.map { line -> | ||
line.split(",").map { it.toInt() } | ||
} | ||
val rules = rulesStr.map { line -> | ||
val (first, second) = line.split("|").map { it.toInt() } | ||
first to second | ||
} | ||
return rules to pages | ||
} | ||
|
||
override val day = "05".toInt() | ||
} |
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,82 @@ | ||
package no.rodland.advent_2024 | ||
|
||
import no.rodland.advent.* | ||
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
import readFile | ||
|
||
// | ||
// run: download_aoc_input.sh to download input | ||
// | ||
|
||
@Suppress("ClassName") | ||
@DisableSlow | ||
internal class Day05Test { | ||
private val data05 = "2024/input_05.txt".readFile() | ||
private val test05 = "2024/input_05_test.txt".readFile() | ||
|
||
private val resultTestOne = 2L | ||
private val resultTestTwo = 2L | ||
private val resultOne = 2L | ||
private val resultTwo = 2L | ||
|
||
val test = defaultTestSuiteParseOnInit( | ||
Day05(data05), | ||
Day05(test05), | ||
resultTestOne, | ||
resultOne, | ||
resultTestTwo, | ||
resultTwo, | ||
{ Day05(data05) }, | ||
{ Day05(test05) }, | ||
) | ||
|
||
@Nested | ||
inner class Init { | ||
@Test | ||
fun `05,-,example,1`() { | ||
report(AOCTest({ "123".toInt() }, Unit, 123, 5, "05".toInt(), Part.TWO, false, "example")) | ||
} | ||
|
||
@Test | ||
fun `05,-,example,2`() { | ||
report(test.initTest.copy()) | ||
} | ||
|
||
@Test | ||
fun `05,-,test,init`() { | ||
report(test.initTest) | ||
} | ||
|
||
@Test | ||
fun `05,-,live,init`() { | ||
report(test.initLive) | ||
} | ||
} | ||
|
||
@Nested | ||
inner class `Part 1` { | ||
@Test | ||
fun `05,1,test`() { | ||
report(test.testPart1) | ||
} | ||
|
||
@Test | ||
fun `05,1,live,1`() { | ||
report(test.livePart1) | ||
} | ||
} | ||
|
||
@Nested | ||
inner class `Part 2` { | ||
@Test | ||
fun `05,2,test`() { | ||
report(test.testPart2) | ||
} | ||
|
||
@Test | ||
fun `05,2,live,1`() { | ||
report(test.livePart2) | ||
} | ||
} | ||
} |
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,28 @@ | ||
47|53 | ||
97|13 | ||
97|61 | ||
97|47 | ||
75|29 | ||
61|13 | ||
75|53 | ||
29|13 | ||
97|29 | ||
53|29 | ||
61|53 | ||
97|53 | ||
61|29 | ||
47|13 | ||
75|47 | ||
97|75 | ||
47|61 | ||
75|61 | ||
47|29 | ||
75|13 | ||
53|13 | ||
|
||
75,47,61,53,29 | ||
97,61,53,29,13 | ||
75,29,13 | ||
75,97,47,61,53 | ||
61,13,29 | ||
97,13,75,29,47 |