Skip to content

Commit f095482

Browse files
committed
Solved day19 part 2
1 parent b4b6f48 commit f095482

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
// project meta data
66
group 'de.havox_design.aoc2023'
7-
version '0.18.7'
7+
version '0.18.8'
88

99
// Switch to gradle "all" distribution.
1010
wrapper {

day19/src/main/kotlin/de/havox_design/aoc2023/day19/RangeAssignment.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ data class RangeAssignment(
1010
val sMin: Long = 1L,
1111
val sMax: Long = 4000L
1212
) {
13+
private val ICON_EXTREMELY_COOL_LOOKING = 'x'
14+
private val ICON_MUSICAL = 'm'
15+
private val ICON_AERODYNAMIC = 'a'
16+
private val ICON_SHINY = 's'
17+
1318
fun split(condition: Condition): Pair<RangeAssignment, RangeAssignment> =
1419
when (condition.field) {
15-
'x' -> when (condition.lessThen) {
20+
ICON_EXTREMELY_COOL_LOOKING -> when (condition.lessThen) {
1621
true -> copy(xMax = condition.value - 1) to copy(xMin = condition.value)
1722
else -> copy(xMin = condition.value + 1) to copy(xMax = condition.value)
1823
}
1924

20-
'm' -> when (condition.lessThen) {
25+
ICON_MUSICAL -> when (condition.lessThen) {
2126
true -> copy(mMax = condition.value - 1) to copy(mMin = condition.value)
2227
else -> copy(mMin = condition.value + 1) to copy(mMax = condition.value)
2328
}
2429

25-
'a' -> when (condition.lessThen) {
30+
ICON_AERODYNAMIC -> when (condition.lessThen) {
2631
true -> copy(aMax = condition.value - 1) to copy(aMin = condition.value)
2732
else -> copy(aMin = condition.value + 1) to copy(aMax = condition.value)
2833
}
2934

30-
's' -> when (condition.lessThen) {
35+
ICON_SHINY -> when (condition.lessThen) {
3136
true -> copy(sMax = condition.value - 1) to copy(sMin = condition.value)
3237
else -> copy(sMin = condition.value + 1) to copy(sMax = condition.value)
3338
}

0 commit comments

Comments
 (0)