Added some comment in day 5 code
This commit is contained in:
@@ -42,6 +42,7 @@ impl Day5 {
|
|||||||
let mut prev = HashSet::new();
|
let mut prev = HashSet::new();
|
||||||
for n in update {
|
for n in update {
|
||||||
if let Some(rule) = self.rule_map.get(n) {
|
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)) {
|
if rule.iter().any(|n2| prev.contains(n2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user