2024(5): halfly fix it, still need to only sum those that were updated
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user