From 665b592b3b218254ba381d1d3d148da9375509a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdulkadir=20Furkan=20=C5=9Eanl=C4=B1?= Date: Wed, 6 Dec 2023 18:06:47 +0100 Subject: [PATCH] Start to rewrite of 5:2 --- 5/2/solution.sh | 136 ++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/5/2/solution.sh b/5/2/solution.sh index 0cddff4..53f04d8 100755 --- a/5/2/solution.sh +++ b/5/2/solution.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# INCOMPLETE + set -o errexit set -o nounset set -o pipefail @@ -7,89 +9,89 @@ if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace fi -cd "$(dirname "$0")" - INPUT_FILE="$1" -get_seed_pairs () +gen_maps () { - IFS=" " read -r -a seeds <<< "$(grep seeds "${INPUT_FILE}" | cut -d ' ' -f 2-)" - seed_count="${#seeds[@]}" - pairs=$((seed_count/2)) - for ((i=0; i "${map_name}.map" - maps+=("${map_name}.map") + local seed_count pair_count i_start i_length start length end + IFS=" " read -r -a seeds <<< "$(grep seeds "${INPUT_FILE}" | cut -d ' ' -f 2-)" + seed_count="${#seeds[@]}" + pair_count=$((seed_count/2)) + for ((i=0; i