diff --git a/2024/day-5/solution-2.sh b/2024/day-5/solution-2.sh index 2cbc576..7505ce1 100644 --- a/2024/day-5/solution-2.sh +++ b/2024/day-5/solution-2.sh @@ -27,7 +27,10 @@ INPUT_RULES=$(cat input-rules) do # Loop through rules and build all the KVs DAG_GREP_EXPR=$( printf "%s" "$CACHED_LINE" | paste -s -d '|' ) - KV_ARRAY=( $( < input-rules grep -E "($DAG_GREP_EXPR)\\|($DAG_GREP_EXPR)" | tr '|' ' ' | paste -s -d ' ') ) + read -r -a KV_ARRAY <<< "$( + < input-rules grep -E "($DAG_GREP_EXPR)\\|($DAG_GREP_EXPR)" | + tr '|' ' ' | + paste -s -d ' ')" # Going through dependencies to find final key KEY=${KV_ARRAY[0]} while true