diff --git a/src/main/kotlin/no/rodland/advent_2023/Day19.kt b/src/main/kotlin/no/rodland/advent_2023/Day19.kt index 5eccd19d..82119c2c 100644 --- a/src/main/kotlin/no/rodland/advent_2023/Day19.kt +++ b/src/main/kotlin/no/rodland/advent_2023/Day19.kt @@ -30,18 +30,16 @@ class Day19(val input: List) : Day + return workflow.filters.sumOf { rule -> val (matchedRule, notMatched) = rule.split(currentRanges) - total += run(rule.destination, matchedRule) currentRanges = notMatched + // if (notMatched.empty) return@sumOf run(rule.destination, matchedRule) + run(rule.destination, matchedRule) } - total += run(workflow.defaultDestination, currentRanges) - return total } @@ -68,12 +66,14 @@ class Day19(val input: List) : Day").substringBefore(":").toInt(), string.substringAfter(":") ) + string.contains("<") -> CheckRule( string.substringBefore("<").first(), false, string.substringAfter("<").substringBefore(":").toInt(), string.substringAfter(":") ) + string == "A" -> acceptRule string == "R" -> rejectRule else -> NoCheckRule(string)