X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2021.git/blobdiff_plain/16c6bf02b28e2d22ce893acdd4de2e4094316e8d..f1b1e23447bb6afd95256acfa9288a8b2680b8ee:/day13/fold.sh?ds=inline diff --git a/day13/fold.sh b/day13/fold.sh index 83e1585..7db1eda 100755 --- a/day13/fold.sh +++ b/day13/fold.sh @@ -91,9 +91,7 @@ fold() { if [ $x_2 -ge $max_x ]; then offset_2=$offset_1 fi - new_map+=("$dot") - new_offset=$((($y * $new_max_x) + $x)) - new_map[$new_offset]=$((${map[$offset_1]} | ${map[$offset_2]})) + new_map+=($((${map[$offset_1]} | ${map[$offset_2]}))) done done map=("${new_map[@]}") @@ -120,9 +118,7 @@ fold() { for (( x=0; x<$max_x; x++ )); do off_1=$(($offset_1+$x)) off_2=$(($offset_2+$x)) - new_map+=("$dot") - new_offset=$((($y * $max_x) + $x)) - new_map[$new_offset]=$((${map[$off_1]} | ${map[$off_2]})) + new_map+=($((${map[$off_1]} | ${map[$off_2]}))) done done map=("${new_map[@]}")