File tree Expand file tree Collapse file tree 6 files changed +23
-11
lines changed
runner/src/commonMain/kotlin/in/procyk/adventofcode/runner
solutions/src/commonMain/kotlin/in/procyk/adventofcode/solutions
commonMain/kotlin/in/procyk/adventofcode/solver
webMain/kotlin/in/procyk/adventofcode/solver Expand file tree Collapse file tree 6 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 11[versions ]
2- compose-multiplatform = " 1.7.0"
3- kotlin = " 2.1.0"
4- kotlinx-coroutines = " 1.9.0"
5- kotlinx-datetime = " 0.6.1"
6- kotlinx-io = " 0.6.0"
2+ compose-multiplatform = " 1.9.3"
3+ kotlin = " 2.2.21"
4+ kotlinx-coroutines = " 1.10.2"
5+ kotlinx-datetime = " 0.7.1"
6+ kotlinx-browser = " 0.5.0"
7+ kotlinx-io = " 0.8.2"
78kotlin-bignum = " 0.3.10"
89
910[libraries ]
@@ -12,6 +13,7 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
1213kotlinx-datetime = { module = " org.jetbrains.kotlinx:kotlinx-datetime" , version.ref = " kotlinx-datetime" }
1314kotlinx-io-core = { module = " org.jetbrains.kotlinx:kotlinx-io-core" , version.ref = " kotlinx-io" }
1415kotlin-bignum = { module = " com.ionspin.kotlin:bignum" , version.ref = " kotlin-bignum" }
16+ kotlinx-browser = { module = " org.jetbrains.kotlinx:kotlinx-browser" , version.ref = " kotlinx-browser" }
1517
1618[plugins ]
1719composeMultiplatform = { id = " org.jetbrains.compose" , version.ref = " compose-multiplatform" }
Original file line number Diff line number Diff line change @@ -4,12 +4,14 @@ import `in`.procyk.adventofcode.solutions.Advent
44import kotlinx.coroutines.*
55import kotlinx.coroutines.channels.Channel
66import kotlinx.coroutines.flow.consumeAsFlow
7+ import kotlin.time.ExperimentalTime
78import kotlin.time.measureTime
89
910fun Advent.solve (
1011 with : FileAdventInputReader = FileAdventInputReader (),
1112) {
1213 runBlocking(Dispatchers .Default ) {
14+ @OptIn(ExperimentalTime ::class )
1315 val today = today()
1416 val debug = Channel <String >()
1517 try {
Original file line number Diff line number Diff line change 11package `in`.procyk.adventofcode.solutions
22
3- import kotlinx.datetime.Clock
4- import kotlinx.datetime.Instant
53import kotlinx.datetime.TimeZone
4+ import kotlinx.datetime.number
65import kotlinx.datetime.toLocalDateTime
6+ import kotlin.time.Clock
7+ import kotlin.time.ExperimentalTime
8+ import kotlin.time.Instant
79
810abstract class Advent {
911 abstract val year: Int
1012 abstract val days: List <AdventDay >
1113
14+ @OptIn(ExperimentalTime ::class )
1215 fun today (now : Instant = Clock .System .now()): AdventDay ? {
1316 val localDateTime = now.toLocalDateTime(TimeZone .of(" UTC-5" ))
1417 if (localDateTime.year != year) return null
15- if (localDateTime.monthNumber != 12 ) return null
16- return days.firstOrNull { it.n == localDateTime.dayOfMonth }
18+ if (localDateTime.month.number != 12 ) return null
19+ return days.firstOrNull { it.n == localDateTime.day }
1720 }
1821}
Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ kotlin {
2222
2323 implementation(compose.foundation)
2424 implementation(compose.material3)
25+ implementation(compose.materialIconsExtended)
2526 implementation(compose.components.resources)
2627 }
28+
29+ webMain.dependencies {
30+ api(libs.kotlinx.browser)
31+ }
2732 }
2833}
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ private inline fun <R : Any> Builder.withColorStyle(
222222private enum class AdventYearStyle (val prefix : String , val suffix : String ) {
223223 Clean (" " , " " ),
224224 Json (" {'year': " , " }" ),
225- Php (" \ $ year = " , " ;" ),
225+ Php ($$ " $year = " , " ;" ),
226226 Yaml (" year: " , " " ),
227227 Python (" year = " , " " ),
228228 Haskell (" λy." , " " ),
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import kotlinx.browser.document
88
99@OptIn(ExperimentalComposeUiApi ::class )
1010fun adventWebSolver (advent : Advent ) {
11- ComposeViewport (document.body !! ) {
11+ ComposeViewport {
1212 AdventSolver (
1313 advent = advent,
1414 onDaySelected = { selectedDay ->
You can’t perform that action at this time.
0 commit comments