From 4937f4715c24cc08b20ed0335b4a6228c20eac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20R=C3=B8dland?= Date: Wed, 20 Dec 2023 08:53:43 +0100 Subject: [PATCH] 2023 - Day 19 - tweaked --- src/main/kotlin/no/rodland/advent_2023/Day19.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)