diff --git a/src/main/kotlin/no/rodland/advent_2023/Day18.kt b/src/main/kotlin/no/rodland/advent_2023/Day18.kt new file mode 100644 index 00000000..7453c7fc --- /dev/null +++ b/src/main/kotlin/no/rodland/advent_2023/Day18.kt @@ -0,0 +1,27 @@ +package no.rodland.advent_2023 + +import no.rodland.advent.Day + +// template generated: 18/12/2023 +// Fredrik Rødland 2023 + +class Day18(val input: List) : Day> { + + private val parsed = input.parse() + + override fun partOne(): Long { + return 2 + } + + override fun partTwo(): Long { + return 2 + } + + override fun List.parse(): List { + return map { line -> + line + } + } + + override val day = "18".toInt() +} diff --git a/src/test/kotlin/no/rodland/advent_2023/Day18Test.kt b/src/test/kotlin/no/rodland/advent_2023/Day18Test.kt new file mode 100644 index 00000000..3bacbd02 --- /dev/null +++ b/src/test/kotlin/no/rodland/advent_2023/Day18Test.kt @@ -0,0 +1,82 @@ +package no.rodland.advent_2023 + +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 Day18Test { + private val data18 = "2023/input_18.txt".readFile() + private val test18 = "2023/input_18_test.txt".readFile() + + private val resultTestOne = 2L + private val resultTestTwo = 2L + private val resultOne = 2L + private val resultTwo = 2L + + val test = defaultTestSuiteParseOnInit( + Day18(data18), + Day18(test18), + resultTestOne, + resultOne, + resultTestTwo, + resultTwo, + { Day18(data18) }, + { Day18(test18) }, + ) + + @Nested + inner class Init { + @Test + fun `18,-,example,1`() { + report(AOCTest({ "123".toInt() }, Unit, 123, 5, "18".toInt(), Part.TWO, false, "example")) + } + + @Test + fun `18,-,example,2`() { + report(test.initTest.copy()) + } + + @Test + fun `18,-,test,init`() { + report(test.initTest) + } + + @Test + fun `18,-,live,init`() { + report(test.initLive) + } + } + + @Nested + inner class `Part 1` { + @Test + fun `18,1,test`() { + report(test.testPart1) + } + + @Test + fun `18,1,live,1`() { + report(test.livePart1) + } + } + + @Nested + inner class `Part 2` { + @Test + fun `18,2,test`() { + report(test.testPart2) + } + + @Test + fun `18,2,live,1`() { + report(test.livePart2) + } + } +} diff --git a/src/test/resources/2023/input_18.txt b/src/test/resources/2023/input_18.txt index e69de29b..2044ef7f 100644 --- a/src/test/resources/2023/input_18.txt +++ b/src/test/resources/2023/input_18.txt @@ -0,0 +1,638 @@ +R 6 (#4d17d2) +U 5 (#af8603) +L 4 (#1ae700) +U 10 (#653071) +R 4 (#14fa90) +U 7 (#35c823) +L 6 (#c3ab30) +U 5 (#35c821) +R 2 (#2a44c0) +U 9 (#653073) +R 5 (#4ec500) +U 4 (#599563) +R 7 (#70e612) +U 6 (#5c15a3) +R 3 (#021392) +U 8 (#3548c1) +L 3 (#e79ac2) +U 8 (#3548c3) +L 9 (#120222) +D 8 (#201843) +L 5 (#4d17d0) +U 7 (#38dc03) +L 3 (#972af2) +U 5 (#62ca13) +L 3 (#59ed62) +U 4 (#0ce593) +L 6 (#02b670) +U 7 (#6ce383) +L 8 (#782cd2) +U 7 (#775203) +R 8 (#782cd0) +U 4 (#26fff3) +R 3 (#02b672) +U 7 (#344fa3) +R 9 (#0bb672) +U 6 (#c6d893) +R 5 (#6002a2) +D 7 (#197413) +R 6 (#3fec92) +D 5 (#bd6723) +R 3 (#1d2472) +U 12 (#a97743) +R 3 (#42ee52) +U 5 (#24b683) +R 7 (#40e860) +D 3 (#7d48c3) +R 2 (#911270) +D 5 (#7d48c1) +R 11 (#39bd90) +D 6 (#01a883) +L 6 (#8b6400) +D 9 (#0612a3) +R 6 (#244b90) +D 3 (#0612a1) +R 2 (#9e8620) +D 4 (#1d6ff3) +R 3 (#627850) +D 6 (#884a43) +R 7 (#2f3bd2) +D 4 (#8130f1) +L 3 (#5f7702) +D 3 (#95a0f3) +L 7 (#5763b2) +D 6 (#95a0f1) +L 4 (#54b952) +D 8 (#8130f3) +L 5 (#7057f2) +D 6 (#c59b73) +R 3 (#058642) +D 7 (#cc6363) +R 5 (#22f310) +D 7 (#6902b3) +L 5 (#ce2540) +D 5 (#0cae43) +R 5 (#638300) +U 2 (#a29981) +R 4 (#06a0f0) +U 9 (#650061) +R 3 (#4ffdd0) +U 8 (#78eab1) +R 4 (#9b00b0) +D 5 (#78eab3) +R 6 (#277320) +U 2 (#650063) +R 6 (#2a5070) +U 5 (#11b471) +R 7 (#372410) +U 10 (#4a1141) +R 6 (#010020) +U 7 (#63e021) +R 10 (#702450) +U 7 (#0823f1) +R 3 (#310c10) +D 14 (#0823f3) +R 4 (#57cab0) +U 9 (#58cf41) +R 5 (#6dd760) +U 6 (#4c3171) +R 5 (#a16b72) +D 5 (#5866c1) +R 7 (#2abf22) +D 3 (#3f05f1) +L 4 (#6b85a2) +D 11 (#73d6a1) +R 4 (#23aac2) +D 4 (#7e4ce1) +R 5 (#9326d2) +D 10 (#3771c3) +R 4 (#459d72) +U 9 (#3771c1) +R 7 (#5b1752) +U 6 (#227be1) +L 10 (#690342) +U 2 (#a912e1) +R 10 (#584650) +U 7 (#6bba31) +L 9 (#84e0a0) +U 5 (#5d9fb1) +R 9 (#6bbd30) +U 4 (#90c101) +R 3 (#53fab0) +U 3 (#47d041) +R 4 (#8cfc00) +U 10 (#2c32d1) +R 7 (#ce5ef0) +U 5 (#428fc1) +R 9 (#ad7d40) +U 4 (#46ee11) +R 3 (#2aa4e0) +U 5 (#6e8611) +L 12 (#926bf0) +U 3 (#7a96b3) +R 5 (#40f7b2) +U 6 (#8bde03) +L 5 (#c7bf92) +U 8 (#4dd953) +R 4 (#544cd2) +U 3 (#5d83c3) +L 4 (#501082) +U 7 (#5233d3) +R 5 (#aea302) +U 3 (#95bb53) +L 10 (#646eb0) +D 3 (#a708f3) +L 8 (#43b150) +D 6 (#3db811) +L 2 (#6188b0) +D 11 (#b31b51) +R 5 (#009f10) +D 3 (#764a21) +R 5 (#6847e0) +D 3 (#a899c3) +L 2 (#408f80) +D 9 (#be83c3) +L 9 (#50e960) +U 9 (#869503) +L 7 (#5425b0) +U 10 (#7a6843) +L 5 (#038960) +U 11 (#6b2233) +L 6 (#e4a4d0) +U 5 (#660ad3) +L 4 (#4ac160) +U 6 (#1312b3) +L 4 (#7acf10) +U 5 (#510723) +L 7 (#087e10) +U 3 (#85e513) +L 4 (#834d22) +U 4 (#031653) +R 9 (#4ac162) +U 2 (#d1cd63) +R 2 (#737d80) +U 8 (#50aa23) +R 5 (#389bf0) +D 4 (#662db1) +R 6 (#54e9c0) +U 6 (#290a51) +R 6 (#7ebc70) +U 6 (#2abbe1) +L 6 (#48a390) +U 5 (#2abbe3) +R 5 (#4db730) +U 3 (#9f5031) +R 5 (#20b330) +D 9 (#db37b3) +R 6 (#6ff200) +D 4 (#502c73) +L 6 (#70b300) +D 7 (#6c06e1) +R 7 (#1000c2) +D 2 (#9e6131) +R 5 (#1000c0) +U 2 (#20fc11) +R 6 (#4fc970) +U 11 (#836601) +R 5 (#10c0a0) +D 5 (#4cdfa1) +R 3 (#9e7a52) +D 8 (#1efc91) +R 5 (#230502) +D 10 (#997e91) +R 3 (#606502) +D 7 (#b87b23) +R 9 (#70b382) +D 7 (#e143c1) +L 5 (#3c8752) +D 5 (#08ff21) +L 7 (#8bbaf0) +D 5 (#52b461) +R 12 (#6b3420) +D 5 (#70ce63) +L 9 (#38a330) +D 3 (#93f4a3) +R 2 (#752e20) +D 10 (#802b21) +R 5 (#306f80) +D 5 (#563c21) +R 8 (#306f82) +D 3 (#2e5bc1) +R 5 (#6bae00) +D 3 (#95f2b1) +L 13 (#286e20) +D 4 (#1c17f3) +R 4 (#2085b0) +D 3 (#3a8d81) +R 8 (#743280) +D 5 (#3a8d83) +L 5 (#769c70) +D 3 (#1c17f1) +L 8 (#0c45b0) +D 3 (#43f2f1) +L 4 (#43c9b0) +D 6 (#06ca11) +R 3 (#824a92) +D 8 (#275081) +R 8 (#c52910) +D 9 (#677741) +R 6 (#2263f0) +D 2 (#30fc71) +R 4 (#e78d02) +D 5 (#2a6b21) +R 11 (#824a90) +D 6 (#1167b1) +R 9 (#2d5730) +D 8 (#63a741) +R 6 (#79ca32) +D 4 (#d3a311) +R 8 (#6b0082) +D 7 (#1e18a1) +L 8 (#630ee2) +D 6 (#271b51) +R 3 (#20b8e2) +D 6 (#502693) +R 3 (#5e2982) +D 6 (#519c73) +R 5 (#426b22) +D 2 (#6316a3) +R 3 (#a094a0) +D 9 (#13fd63) +R 3 (#159c72) +D 12 (#4a19f3) +R 6 (#2ea222) +D 3 (#4ff3e3) +R 8 (#792c20) +D 3 (#3d9173) +R 4 (#792c22) +D 7 (#5c1193) +R 6 (#604e82) +D 6 (#5b3771) +R 3 (#4e0902) +D 6 (#685f81) +L 11 (#4e0900) +D 5 (#25fff1) +R 11 (#63e382) +D 4 (#3d4d93) +R 5 (#2f6682) +D 3 (#3d4d91) +R 8 (#d3cd42) +D 3 (#4a19f1) +R 5 (#4d60f2) +D 3 (#4cab81) +R 9 (#5a3bb0) +D 5 (#9d4081) +R 4 (#8bf760) +D 4 (#312861) +R 3 (#191a80) +U 10 (#81a9d1) +R 3 (#642c20) +U 9 (#7c6fe1) +R 7 (#6ba570) +U 8 (#4f5c41) +R 3 (#c90d22) +U 5 (#45b391) +L 4 (#c2fd52) +U 5 (#0e4c01) +L 6 (#4a2a62) +U 8 (#c58881) +R 5 (#4a0f92) +U 4 (#0f46c1) +R 13 (#a61822) +D 3 (#0cd461) +R 3 (#05aa52) +D 5 (#02b481) +R 6 (#3ac852) +D 2 (#753603) +R 7 (#0fbaa2) +D 4 (#51ee63) +R 14 (#8c3d12) +D 3 (#8dca01) +R 4 (#0fc982) +D 6 (#395a61) +R 4 (#57e672) +U 6 (#02b483) +R 12 (#423cf2) +D 6 (#3447f1) +R 5 (#892220) +D 4 (#999421) +L 3 (#676720) +D 6 (#999423) +L 7 (#5abd20) +D 3 (#b449e1) +L 2 (#6a69f0) +D 6 (#1c7861) +R 7 (#3898b0) +D 6 (#79e643) +L 7 (#a65d70) +D 7 (#92d4c3) +L 7 (#1f0ff0) +U 6 (#748851) +L 3 (#525540) +D 7 (#471711) +L 2 (#30c320) +D 5 (#471713) +L 4 (#7def00) +U 2 (#598b61) +L 4 (#75c6d2) +U 10 (#085d03) +L 3 (#55e0d2) +U 6 (#085d01) +R 5 (#355fc2) +U 4 (#3ea751) +R 11 (#2ce9f0) +U 3 (#1c7863) +L 7 (#51cd30) +U 3 (#976e41) +L 10 (#4f9750) +D 5 (#1bfbb1) +L 3 (#58a5c0) +D 8 (#1beb31) +L 10 (#5251d0) +D 6 (#2c5001) +L 3 (#63a530) +D 7 (#5e69d1) +L 7 (#1da410) +D 6 (#815311) +L 3 (#59eb40) +D 7 (#b45de3) +L 2 (#494d90) +D 9 (#b45de1) +L 8 (#646ee0) +U 7 (#8093c1) +L 4 (#7b5e60) +U 5 (#2c2371) +L 7 (#81f5a0) +D 6 (#2e57a1) +L 9 (#c8e0a0) +D 6 (#0869d1) +L 6 (#57dc30) +U 9 (#b23011) +L 3 (#82d280) +D 4 (#9c7a61) +L 9 (#436352) +U 4 (#01ff51) +L 5 (#870b32) +D 5 (#48a8f1) +L 4 (#1fb772) +U 9 (#1d4661) +L 5 (#4e52c0) +U 9 (#a9a371) +L 4 (#586fe0) +U 3 (#0b9431) +L 3 (#277592) +D 4 (#14b641) +L 4 (#3a0dc0) +D 4 (#4455a1) +R 5 (#5469b0) +D 9 (#a84ea1) +L 5 (#8e7772) +D 4 (#335031) +L 3 (#130b82) +U 5 (#bc0881) +L 8 (#717632) +U 4 (#063d31) +R 5 (#107a82) +U 3 (#2a1d41) +L 5 (#afce92) +U 6 (#2a1d43) +L 3 (#5defe2) +U 5 (#063d33) +R 8 (#2cd1d2) +U 4 (#9c0681) +L 5 (#1e4382) +U 4 (#36ccb1) +L 8 (#e207d2) +D 3 (#36ccb3) +L 5 (#5dc9c2) +D 7 (#8ea673) +R 5 (#137612) +D 7 (#2a7283) +L 8 (#6900b0) +U 10 (#2f0cd3) +L 6 (#7eac90) +D 3 (#7ddfb3) +L 4 (#6148d0) +D 6 (#bf9c13) +L 5 (#18df50) +D 4 (#1355a3) +R 5 (#60fd80) +D 8 (#6d26c3) +L 5 (#9d0910) +D 2 (#6d26c1) +L 4 (#0b62f0) +U 6 (#1e4cb1) +L 12 (#076920) +U 4 (#b4a501) +L 8 (#73a1b0) +U 7 (#35ca73) +R 5 (#4ac3d0) +U 4 (#5fb103) +R 2 (#4ac3d2) +U 8 (#7eb2a3) +R 4 (#606002) +D 7 (#835373) +R 2 (#2c6042) +D 5 (#217003) +R 7 (#5694d2) +U 6 (#4362e3) +L 4 (#8f6f82) +U 9 (#3ea893) +R 4 (#074f80) +U 3 (#7f3203) +R 8 (#1eee40) +U 3 (#17dba3) +R 5 (#958930) +D 6 (#17dba1) +R 5 (#41cfe0) +U 3 (#2cff03) +R 6 (#4ff132) +U 6 (#5edd73) +L 2 (#2fdd32) +U 5 (#4f6a83) +L 6 (#7dc872) +U 5 (#4a4d43) +L 9 (#d27932) +U 3 (#4a8801) +L 5 (#9e0cd2) +U 3 (#a57a91) +L 4 (#a6e7e0) +U 4 (#adbef1) +L 2 (#a6e7e2) +U 10 (#476741) +L 7 (#249cf0) +U 4 (#9abc41) +L 3 (#249cf2) +U 3 (#4bb011) +L 9 (#02ff22) +U 7 (#6d4ea3) +L 8 (#5ee6e2) +U 6 (#61eb43) +L 4 (#5ee6e0) +U 7 (#607293) +L 3 (#a6dd82) +U 3 (#7acf31) +L 8 (#579bb2) +D 4 (#6f1ec1) +L 7 (#579bb0) +D 3 (#3a3891) +L 4 (#49cfe2) +D 5 (#1b2e01) +L 5 (#696b92) +U 12 (#733c23) +L 4 (#1fef72) +D 12 (#6485c3) +L 4 (#08ff32) +D 6 (#6792a3) +R 8 (#929a72) +D 3 (#22f4e1) +R 6 (#32d2b2) +D 4 (#a977b1) +L 3 (#9b3ea2) +D 6 (#ad3b21) +L 5 (#716be2) +D 9 (#9b4a11) +R 8 (#01d322) +D 3 (#1f6901) +L 5 (#8defc2) +D 6 (#453b51) +L 9 (#3bf332) +D 9 (#c4b591) +R 4 (#62f012) +D 5 (#6e3221) +R 7 (#271ae2) +D 4 (#5a8111) +R 9 (#8e21a2) +D 4 (#c26333) +L 10 (#77d0d0) +D 5 (#5d1b63) +L 6 (#77d0d2) +D 5 (#695443) +L 7 (#009572) +D 4 (#1a9de3) +L 7 (#016772) +D 2 (#5a0151) +L 6 (#b606a2) +D 4 (#5a0153) +L 7 (#537112) +D 3 (#0259c3) +L 7 (#040d52) +D 6 (#5a0893) +L 5 (#a70252) +D 9 (#5a5053) +L 3 (#423eb2) +D 4 (#555853) +L 8 (#6560d0) +D 3 (#235cc1) +L 9 (#7ebac0) +D 3 (#235cc3) +L 2 (#052570) +D 6 (#3999b3) +L 5 (#717242) +D 3 (#218633) +L 5 (#3d2bc0) +D 3 (#1eac81) +L 7 (#d703a0) +U 6 (#1eac83) +L 3 (#6c2f50) +U 3 (#500333) +L 2 (#009570) +U 4 (#caaf63) +L 4 (#67b322) +U 12 (#3fb3e3) +L 3 (#91ae82) +U 4 (#41e513) +L 5 (#230d72) +U 5 (#72a203) +L 7 (#781422) +D 5 (#0f87c1) +L 3 (#ccb092) +U 3 (#02c7c1) +L 5 (#507412) +U 2 (#0a7d21) +L 4 (#6d22b0) +U 12 (#5b8b11) +L 3 (#0e39c2) +U 3 (#4847e1) +R 4 (#63e4b0) +U 3 (#46cd91) +R 9 (#63e4b2) +U 3 (#59c031) +R 4 (#0e39c0) +D 6 (#07f351) +R 3 (#6d22b2) +U 9 (#0c6021) +L 3 (#1ce1c2) +U 11 (#303b83) +L 6 (#453a82) +D 3 (#0db0b1) +L 4 (#6f51d2) +D 8 (#2a9e11) +L 4 (#256792) +U 2 (#b9fc51) +L 3 (#554e12) +U 6 (#1a6743) +R 2 (#425450) +U 6 (#802a53) +R 6 (#425452) +U 5 (#57b983) +R 6 (#24dab2) +D 5 (#a861e3) +R 5 (#03a640) +U 5 (#0cf633) +R 4 (#12e8b0) +U 3 (#670cd3) +R 7 (#9404a0) +U 3 (#6b1da3) +L 8 (#124400) +U 4 (#490281) +L 9 (#565b30) +U 4 (#9605b1) +L 3 (#340010) +U 4 (#001871) +L 4 (#0ce9d0) +U 6 (#9ce363) +L 7 (#954302) +D 8 (#5e50d3) +L 6 (#1bdbb0) +D 4 (#bfa473) +L 3 (#9282e0) +D 6 (#adcac3) +L 5 (#101580) +U 3 (#3829f3) +L 6 (#856420) +U 6 (#13ee53) +L 9 (#4f1fc0) +U 4 (#beec51) +R 8 (#27fce0) +U 2 (#3af6b1) +R 7 (#8c68b0) +U 6 (#625da3) +L 6 (#8094f2) +U 5 (#00afc3) +R 5 (#46b230) +U 7 (#388223) +R 9 (#792f52) +D 6 (#c18f43) +R 4 (#792f50) +U 11 (#51b883) +R 2 (#46b232) +U 2 (#3e9823) +R 3 (#9d1b32) +D 5 (#32d503) +R 3 (#167db2) +D 8 (#b22773) +R 4 (#4bca32) +U 6 (#b64b13) +R 8 (#227362) +D 7 (#5ae973) +R 10 (#8c0eb2) +U 2 (#29cc41) +R 3 (#350bf0) +U 10 (#6a2c51) +L 7 (#350bf2) +U 2 (#7d3bf1) +L 7 (#259fe2) +U 8 (#745a53) +L 6 (#c1add2) +U 6 (#1063f3) diff --git a/src/test/resources/2023/input_18_test.txt b/src/test/resources/2023/input_18_test.txt new file mode 100644 index 00000000..e69de29b