Cleanup
This commit is contained in:
parent
f9d37a028a
commit
8ccbf40783
@ -31,7 +31,6 @@ main ()
|
|||||||
possible_ids+=($id)
|
possible_ids+=($id)
|
||||||
fi
|
fi
|
||||||
done < input.txt
|
done < input.txt
|
||||||
echo "${possible_ids[@]}"
|
|
||||||
declare -i sum=0
|
declare -i sum=0
|
||||||
for id in "${possible_ids[@]}"; do
|
for id in "${possible_ids[@]}"; do
|
||||||
(( sum+=id ))
|
(( sum+=id ))
|
||||||
|
@ -15,7 +15,6 @@ main ()
|
|||||||
while read -r line; do
|
while read -r line; do
|
||||||
declare -a winning=() mine=() mywinning=()
|
declare -a winning=() mine=() mywinning=()
|
||||||
declare -i card_sum=0
|
declare -i card_sum=0
|
||||||
echo "$line"
|
|
||||||
stripped=$(sed 's/Card\s\{1,3\}[0-9]\{1,3\}: //' <<< "${line}")
|
stripped=$(sed 's/Card\s\{1,3\}[0-9]\{1,3\}: //' <<< "${line}")
|
||||||
winning+=($(cut -d '|' -f 1 <<< "${stripped}"))
|
winning+=($(cut -d '|' -f 1 <<< "${stripped}"))
|
||||||
mine+=($(cut -d '|' -f 2 <<< "${stripped}"))
|
mine+=($(cut -d '|' -f 2 <<< "${stripped}"))
|
||||||
@ -27,7 +26,6 @@ main ()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
echo mywwinning ${mywinning[@]}
|
|
||||||
for number in "${mywinning[@]}"; do
|
for number in "${mywinning[@]}"; do
|
||||||
if [[ card_sum -eq 0 ]]; then
|
if [[ card_sum -eq 0 ]]; then
|
||||||
card_sum=$((card_sum+1))
|
card_sum=$((card_sum+1))
|
||||||
@ -35,9 +33,7 @@ main ()
|
|||||||
card_sum=$((card_sum*2))
|
card_sum=$((card_sum*2))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "card sum: $card_sum"
|
|
||||||
sum=$((sum+card_sum))
|
sum=$((sum+card_sum))
|
||||||
echo "sum: ${sum}"
|
|
||||||
done < input.txt
|
done < input.txt
|
||||||
echo "${sum}"
|
echo "${sum}"
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ CARDS="${#INPUT[@]}"
|
|||||||
|
|
||||||
run_cards ()
|
run_cards ()
|
||||||
{
|
{
|
||||||
# Receives space separated list of cards I have.
|
|
||||||
for ((x=1; x<=CARDS; x++)); do
|
for ((x=1; x<=CARDS; x++)); do
|
||||||
declare -a winning=() mine=()
|
declare -a winning=() mine=()
|
||||||
declare -i matching=0
|
declare -i matching=0
|
||||||
@ -45,7 +44,6 @@ main ()
|
|||||||
done
|
done
|
||||||
run_cards "${hand[@]}"
|
run_cards "${hand[@]}"
|
||||||
for ((z=1; z<=CARDS; z++)); do
|
for ((z=1; z<=CARDS; z++)); do
|
||||||
echo "card $z: ${hand[$z]}"
|
|
||||||
sum=$((sum+${hand[$z]}))
|
sum=$((sum+${hand[$z]}))
|
||||||
done
|
done
|
||||||
echo "${sum}"
|
echo "${sum}"
|
||||||
|
Loading…
Reference in New Issue
Block a user