2024(5): halfly fix it, still need to only sum those that were updated

This commit is contained in:
2024-12-19 13:45:32 +01:00
parent 041fa92a26
commit 1ed8961019
2 changed files with 72 additions and 1 deletions

View File

@ -31,7 +31,7 @@ def load_input(filename="input"):
return rules, updates
def is_update_legal(update, rules) -> bool:
def is_update_legal(update, rules, print_offence=False) -> bool:
for rule in rules:
# Find indices of left hand side and right hand side
lhs, rhs = rule
@ -41,6 +41,8 @@ def is_update_legal(update, rules) -> bool:
# This reminds me of limes inferior and limes superior.
# Thanks, Mueger.
if max(indices(update, lhs)) > min(indices(update, rhs)):
if print_offence:
print(f"Rule", rule, "offended by update", update)
return False
return True