Added some comment in day 5 code

This commit is contained in:
2024-12-05 23:43:29 +01:00
parent 108c395432
commit 84cf38b1bc

View File

@@ -42,6 +42,7 @@ impl Day5 {
let mut prev = HashSet::new();
for n in update {
if let Some(rule) = self.rule_map.get(n) {
// The rule_map maps from a number A to a set of numbers that should come after it. So if one of those numbers was seen previously, this rule is in the wrong order.
if rule.iter().any(|n2| prev.contains(n2)) {
return false;
}