]> git.sommitrealweird.co.uk Git - advent-of-code-2021.git/blobdiff - day13/fold.sh
Day 14
[advent-of-code-2021.git] / day13 / fold.sh
index 83e15850e854dbbac65cdef6d144a6861c472ae1..7db1edac277556f16b304a191b76d8727420c2b7 100755 (executable)
@@ -91,9 +91,7 @@ fold() {
                     if [ $x_2 -ge $max_x  ]; then
                         offset_2=$offset_1
                     fi
                     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[@]}")
                 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))
                 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[@]}")
                 done
             done
             map=("${new_map[@]}")