diff --git a/2024/day-5/solution-2.sh b/2024/day-5/solution-2.sh index 5c88056..be100e7 100644 --- a/2024/day-5/solution-2.sh +++ b/2024/day-5/solution-2.sh @@ -4,7 +4,7 @@ while read -r LINE do GREP_EXPR=$( printf "%s" "$LINE" | tr ',' '|' ) - PASS_RULES=0 + MATCH_COUNT=0 # Loop through rules and find a breaking rule while read -r RULE do @@ -12,14 +12,14 @@ if [[ $GREPC -ne 1 ]] then #printf "%s rule violated for %s \n" "$RULE" "$LINE" - PASS_RULES=1 + MATCH_COUNT=1 break fi # Filter rules that only has included pages done <<< "$( < input-rules grep -E "($GREP_EXPR)\\|($GREP_EXPR)" | sed 's/|/,.*/')" # Don't process for valid lines - [[ $PASS_RULES -eq 0 ]] && continue + [[ $MATCH_COUNT -eq 0 ]] && continue printf "%s\n" "$LINE" done < input-updates