diff --git a/README.md b/README.md
index 6fecd855..0d712d56 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,13 @@ fmmr solutions for Advent of code.
![stars](gifs/stars.png?raw=true "ascii art")
+## 2023
+
+[AOC](https://adventofcode.com/2024),
+[Implementations](https://github.com/fmmr/advent/tree/master/src/main/kotlin/no/rodland/advent_2024),
+[Tests](https://github.com/fmmr/advent/tree/master/src/test/kotlin/no/rodland/advent_2024)
+
+
## 2023
[AOC](https://adventofcode.com/2023),
diff --git a/pom.xml b/pom.xml
index 3658fb28..a4170b4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,22 +10,22 @@
UTF-8
- 21
- 21
+ 22
+ 22
- 1.9.22
- 21
+ 2.0.21
+ 22
true
- 3.24.2
- 32.1.3-jre
- 0.8.11
+ 3.26.3
+ 33.3.1-jre
+ 0.8.12
1.5.2
- 5.10.1
+ 5.11.3
5.6
- 1.7.3
- 3.11.0
- 3.2.2
+ 1.9.0
+ 3.13.0
+ 3.5.2
1.1.1
diff --git a/src/main/kotlin/no/rodland/advent_2019/Day07.kt b/src/main/kotlin/no/rodland/advent_2019/Day07.kt
index b9cb8201..25317be1 100644
--- a/src/main/kotlin/no/rodland/advent_2019/Day07.kt
+++ b/src/main/kotlin/no/rodland/advent_2019/Day07.kt
@@ -3,79 +3,78 @@ package no.rodland.advent_2019
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
-import kotlinx.coroutines.channels.BroadcastChannel
-import kotlinx.coroutines.channels.Channel
-import kotlinx.coroutines.channels.toList
-import kotlinx.coroutines.runBlocking
@DelicateCoroutinesApi
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
object Day07 {
- fun partOne(program: List): Long {
- return permute(0..4).map { runBlocking { runAmplifiersPart1(program, it) } }.maxOrNull()!!
- }
- fun partTwo(program: List): Long {
- val map = permute(5..9).map { runBlocking { runAmplifiersPart2(program, it) } }
- return map.maxOrNull()!!
- }
+ // 20241118 commented out because BroadcastChannel is deprecated with ERROR. no simple replacement afaik.
- @ExperimentalCoroutinesApi
- @Suppress("DEPRECATION")
- private suspend fun runAmplifiersPart2(program: List, phases: List): Long {
-
- val broadcast = BroadcastChannel(20)
-
- val sniffer = broadcast.openSubscription()
- val ea = broadcast.openSubscription()
- val ab = Channel(20)
- val bc = Channel(20)
- val cd = Channel(20)
- val de = Channel(20)
-
- // set ut channels initially
- broadcast.send(phases[0])
- broadcast.send(0)
-
- ab.send(phases[1])
- bc.send(phases[2])
- cd.send(phases[3])
- de.send(phases[4])
-
-
- // start each amplifier (justDoIt will do a launch)
- val intCodeComputer4 = IntCodeComputer()
- intCodeComputer4.launch(program, bc, cd)
- val intCodeComputer3 = IntCodeComputer()
- intCodeComputer3.launch(program, ea, ab)
- val intCodeComputer2 = IntCodeComputer()
- intCodeComputer2.launch(program, ab, bc)
- val intCodeComputer1 = IntCodeComputer()
- intCodeComputer1.launch(program, cd, de)
- val intCodeComputer = IntCodeComputer()
- intCodeComputer.launch(program, de, broadcast)
-
- return sniffer.toList().last()
- }
-
- @ExperimentalCoroutinesApi
- private suspend fun runAmplifiersPart1(program: List, phases: List): Long {
- var tmp = runAmp(program, phases[0], 0)
- tmp = runAmp(program, phases[1], tmp)
- tmp = runAmp(program, phases[2], tmp)
- tmp = runAmp(program, phases[3], tmp)
- return runAmp(program, phases[4], tmp)
- }
-
-
- suspend fun runAmp(program: List, first: Long, second: Long): Long {
- val inCh = Channel(20)
- inCh.send(first)
- inCh.send(second)
- val list = mutableListOf()
- IntCodeComputer().runSuspend(program, { inCh.receive() }, { list.add(it) })
- return list.last()
- }
+// fun partOne(program: List): Long {
+// return permute(0..4).map { runBlocking { runAmplifiersPart1(program, it) } }.maxOrNull()!!
+// }
+//
+// fun partTwo(program: List): Long {
+// val map = permute(5..9).map { runBlocking { runAmplifiersPart2(program, it) } }
+// return map.maxOrNull()!!
+// }
+//
+// @ExperimentalCoroutinesApi
+// @Suppress("DEPRECATION")
+// private suspend fun runAmplifiersPart2(program: List, phases: List): Long {
+//
+// val broadcast = BroadcastChannel(20)
+//
+// val sniffer = broadcast.openSubscription()
+// val ea = broadcast.openSubscription()
+// val ab = Channel(20)
+// val bc = Channel(20)
+// val cd = Channel(20)
+// val de = Channel(20)
+//
+// // set ut channels initially
+// broadcast.send(phases[0])
+// broadcast.send(0)
+//
+// ab.send(phases[1])
+// bc.send(phases[2])
+// cd.send(phases[3])
+// de.send(phases[4])
+//
+//
+// // start each amplifier (justDoIt will do a launch)
+// val intCodeComputer4 = IntCodeComputer()
+// intCodeComputer4.launch(program, bc, cd)
+// val intCodeComputer3 = IntCodeComputer()
+// intCodeComputer3.launch(program, ea, ab)
+// val intCodeComputer2 = IntCodeComputer()
+// intCodeComputer2.launch(program, ab, bc)
+// val intCodeComputer1 = IntCodeComputer()
+// intCodeComputer1.launch(program, cd, de)
+// val intCodeComputer = IntCodeComputer()
+// intCodeComputer.launch(program, de, broadcast)
+//
+// return sniffer.toList().last()
+// }
+//
+// @ExperimentalCoroutinesApi
+// private suspend fun runAmplifiersPart1(program: List, phases: List): Long {
+// var tmp = runAmp(program, phases[0], 0)
+// tmp = runAmp(program, phases[1], tmp)
+// tmp = runAmp(program, phases[2], tmp)
+// tmp = runAmp(program, phases[3], tmp)
+// return runAmp(program, phases[4], tmp)
+// }
+//
+//
+// suspend fun runAmp(program: List, first: Long, second: Long): Long {
+// val inCh = Channel(20)
+// inCh.send(first)
+// inCh.send(second)
+// val list = mutableListOf()
+// IntCodeComputer().runSuspend(program, { inCh.receive() }, { list.add(it) })
+// return list.last()
+// }
}
diff --git a/src/main/kotlin/no/rodland/advent_2024/Day01.kt b/src/main/kotlin/no/rodland/advent_2024/Day01.kt
new file mode 100644
index 00000000..04aa85ea
--- /dev/null
+++ b/src/main/kotlin/no/rodland/advent_2024/Day01.kt
@@ -0,0 +1,27 @@
+package no.rodland.advent_2024
+
+import no.rodland.advent.Day
+
+// template generated: 18/11/2024
+// Fredrik Rødland 2024
+
+class Day01(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 = "01".toInt()
+}
diff --git a/src/test/kotlin/no/rodland/advent_2019/Day07Test.kt b/src/test/kotlin/no/rodland/advent_2019/Day07Test.kt
index 73227575..d5e7fdb5 100644
--- a/src/test/kotlin/no/rodland/advent_2019/Day07Test.kt
+++ b/src/test/kotlin/no/rodland/advent_2019/Day07Test.kt
@@ -15,64 +15,64 @@ import org.junit.jupiter.api.Test
internal class Day07Test {
val data07 = "2019/input_07.txt".readFirstLineStrings()
- @Nested
- inner class `Part 1` {
- @Test
- fun `07,1,test,1`() {
- report {
- Day07.partOne(listOf("3", "15", "3", "16", "1002", "16", "10", "16", "1", "16", "15", "15", "4", "15", "99", "0", "0")) to 43210L
- }
- }
-
- @Test
- fun `07,1,test,2`() {
- report {
- val program = listOf("3", "23", "3", "24", "1002", "24", "10", "24", "1002", "23", "-1", "23", "101", "5", "23", "23", "1", "24", "23", "23", "4", "23", "99", "0", "0")
- Day07.partOne(program) to 54321L
- }
- }
-
- @Test
- fun `07,1,test,3`() {
- report {
- val program = listOf("3", "31", "3", "32", "1002", "32", "10", "32", "1001", "31", "-2", "31", "1007", "31", "0", "33", "1002", "33", "7", "33", "1", "33", "31", "31", "1", "32", "31", "31", "4", "31", "99", "0", "0", "0")
- Day07.partOne(program) to 65210L
- }
- }
-
- @Test
- fun `07,1,live`() {
- report {
- Day07.partOne(data07) to 79723L
- }
- }
- }
-
- @Nested
- inner class `Part 2` {
- @Test
- fun `07,2,test,1`() {
- report {
- val program = listOf("3", "26", "1001", "26", "-4", "26", "3", "27", "1002", "27", "2", "27", "1", "27", "26", "27", "4", "27", "1001", "28", "-1", "28", "1005", "28", "6", "99", "0", "0", "5")
- Day07.partTwo(program) to 139629729L
- }
- }
-
- @Test
- fun `07,2,test,2`() {
- report {
- val program = listOf("3", "52", "1001", "52", "-5", "52", "3", "53", "1", "52", "56", "54", "1007", "54", "5", "55", "1005", "55", "26", "1001", "54", "-5", "54", "1105", "1", "12", "1", "53", "54", "53", "1008", "54", "0", "55", "1001", "55", "1", "55", "2", "53", "55", "53", "4", "53", "1001", "56", "-1", "56", "1005", "56", "6", "99", "0", "0", "0", "0", "10")
- Day07.partTwo(program) to 18216L
- }
- }
-
- @Test
- fun `07,2,live`() {
- report {
- Day07.partTwo(data07) to 70602018L
- }
- }
- }
+// @Nested
+// inner class `Part 1` {
+// @Test
+// fun `07,1,test,1`() {
+// report {
+// Day07.partOne(listOf("3", "15", "3", "16", "1002", "16", "10", "16", "1", "16", "15", "15", "4", "15", "99", "0", "0")) to 43210L
+// }
+// }
+//
+// @Test
+// fun `07,1,test,2`() {
+// report {
+// val program = listOf("3", "23", "3", "24", "1002", "24", "10", "24", "1002", "23", "-1", "23", "101", "5", "23", "23", "1", "24", "23", "23", "4", "23", "99", "0", "0")
+// Day07.partOne(program) to 54321L
+// }
+// }
+//
+// @Test
+// fun `07,1,test,3`() {
+// report {
+// val program = listOf("3", "31", "3", "32", "1002", "32", "10", "32", "1001", "31", "-2", "31", "1007", "31", "0", "33", "1002", "33", "7", "33", "1", "33", "31", "31", "1", "32", "31", "31", "4", "31", "99", "0", "0", "0")
+// Day07.partOne(program) to 65210L
+// }
+// }
+//
+// @Test
+// fun `07,1,live`() {
+// report {
+// Day07.partOne(data07) to 79723L
+// }
+// }
+// }
+//
+// @Nested
+// inner class `Part 2` {
+// @Test
+// fun `07,2,test,1`() {
+// report {
+// val program = listOf("3", "26", "1001", "26", "-4", "26", "3", "27", "1002", "27", "2", "27", "1", "27", "26", "27", "4", "27", "1001", "28", "-1", "28", "1005", "28", "6", "99", "0", "0", "5")
+// Day07.partTwo(program) to 139629729L
+// }
+// }
+//
+// @Test
+// fun `07,2,test,2`() {
+// report {
+// val program = listOf("3", "52", "1001", "52", "-5", "52", "3", "53", "1", "52", "56", "54", "1007", "54", "5", "55", "1005", "55", "26", "1001", "54", "-5", "54", "1105", "1", "12", "1", "53", "54", "53", "1008", "54", "0", "55", "1001", "55", "1", "55", "2", "53", "55", "53", "4", "53", "1001", "56", "-1", "56", "1005", "56", "6", "99", "0", "0", "0", "0", "10")
+// Day07.partTwo(program) to 18216L
+// }
+// }
+//
+// @Test
+// fun `07,2,live`() {
+// report {
+// Day07.partTwo(data07) to 70602018L
+// }
+// }
+// }
}
diff --git a/src/test/kotlin/no/rodland/advent_2024/Day01Test.kt b/src/test/kotlin/no/rodland/advent_2024/Day01Test.kt
new file mode 100644
index 00000000..d817ff2c
--- /dev/null
+++ b/src/test/kotlin/no/rodland/advent_2024/Day01Test.kt
@@ -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 Day01Test {
+ private val data01 = "2024/input_01.txt".readFile()
+ private val test01 = "2024/input_01_test.txt".readFile()
+
+ private val resultTestOne = 2L
+ private val resultTestTwo = 2L
+ private val resultOne = 2L
+ private val resultTwo = 2L
+
+ val test = defaultTestSuiteParseOnInit(
+ Day01(data01),
+ Day01(test01),
+ resultTestOne,
+ resultOne,
+ resultTestTwo,
+ resultTwo,
+ { Day01(data01) },
+ { Day01(test01) },
+ )
+
+ @Nested
+ inner class Init {
+ @Test
+ fun `01,-,example,1`() {
+ report(AOCTest({ "123".toInt() }, Unit, 123, 5, "01".toInt(), Part.TWO, false, "example"))
+ }
+
+ @Test
+ fun `01,-,example,2`() {
+ report(test.initTest.copy())
+ }
+
+ @Test
+ fun `01,-,test,init`() {
+ report(test.initTest)
+ }
+
+ @Test
+ fun `01,-,live,init`() {
+ report(test.initLive)
+ }
+ }
+
+ @Nested
+ inner class `Part 1` {
+ @Test
+ fun `01,1,test`() {
+ report(test.testPart1)
+ }
+
+ @Test
+ fun `01,1,live,1`() {
+ report(test.livePart1)
+ }
+ }
+
+ @Nested
+ inner class `Part 2` {
+ @Test
+ fun `01,2,test`() {
+ report(test.testPart2)
+ }
+
+ @Test
+ fun `01,2,live,1`() {
+ report(test.livePart2)
+ }
+ }
+}
diff --git a/src/test/resources/2024/input_01.txt b/src/test/resources/2024/input_01.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_02.txt b/src/test/resources/2024/input_02.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_03.txt b/src/test/resources/2024/input_03.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_04.txt b/src/test/resources/2024/input_04.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_05.txt b/src/test/resources/2024/input_05.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_06.txt b/src/test/resources/2024/input_06.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_07.txt b/src/test/resources/2024/input_07.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_08.txt b/src/test/resources/2024/input_08.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_09.txt b/src/test/resources/2024/input_09.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_10.txt b/src/test/resources/2024/input_10.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_11.txt b/src/test/resources/2024/input_11.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_12.txt b/src/test/resources/2024/input_12.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_13.txt b/src/test/resources/2024/input_13.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_14.txt b/src/test/resources/2024/input_14.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_15.txt b/src/test/resources/2024/input_15.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_16.txt b/src/test/resources/2024/input_16.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_17.txt b/src/test/resources/2024/input_17.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_18.txt b/src/test/resources/2024/input_18.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_19.txt b/src/test/resources/2024/input_19.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_20.txt b/src/test/resources/2024/input_20.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_21.txt b/src/test/resources/2024/input_21.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_22.txt b/src/test/resources/2024/input_22.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_23.txt b/src/test/resources/2024/input_23.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_24.txt b/src/test/resources/2024/input_24.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/resources/2024/input_25.txt b/src/test/resources/2024/input_25.txt
new file mode 100644
index 00000000..e69de29b