This commit is contained in:
Abdulkadir Furkan Şanlı 2023-12-05 14:15:19 +01:00
parent f9d37a028a
commit 8ccbf40783
Signed by: afk
GPG Key ID: C8F00588EE6ED1FE
3 changed files with 0 additions and 7 deletions

View File

@ -31,7 +31,6 @@ main ()
possible_ids+=($id)
fi
done < input.txt
echo "${possible_ids[@]}"
declare -i sum=0
for id in "${possible_ids[@]}"; do
(( sum+=id ))

View File

@ -15,7 +15,6 @@ main ()
while read -r line; do
declare -a winning=() mine=() mywinning=()
declare -i card_sum=0
echo "$line"
stripped=$(sed 's/Card\s\{1,3\}[0-9]\{1,3\}: //' <<< "${line}")
winning+=($(cut -d '|' -f 1 <<< "${stripped}"))
mine+=($(cut -d '|' -f 2 <<< "${stripped}"))
@ -27,7 +26,6 @@ main ()
fi
done
done
echo mywwinning ${mywinning[@]}
for number in "${mywinning[@]}"; do
if [[ card_sum -eq 0 ]]; then
card_sum=$((card_sum+1))
@ -35,9 +33,7 @@ main ()
card_sum=$((card_sum*2))
fi
done
echo "card sum: $card_sum"
sum=$((sum+card_sum))
echo "sum: ${sum}"
done < input.txt
echo "${sum}"
}

View File

@ -14,7 +14,6 @@ CARDS="${#INPUT[@]}"
run_cards ()
{
# Receives space separated list of cards I have.
for ((x=1; x<=CARDS; x++)); do
declare -a winning=() mine=()
declare -i matching=0
@ -45,7 +44,6 @@ main ()
done
run_cards "${hand[@]}"
for ((z=1; z<=CARDS; z++)); do
echo "card $z: ${hand[$z]}"
sum=$((sum+${hand[$z]}))
done
echo "${sum}"