Print total solutions.

This commit is contained in:
FiveMovesAhead 2024-09-12 18:44:19 +08:00
parent 41b5a5890e
commit 078ea823ac

View File

@ -9,9 +9,18 @@ RESP=$(curl -s "https://mainnet-api.tig.foundation/get-benchmarks?block_id=$BLOC
BENCHMARKS=$(echo $RESP | jq -c '[.benchmarks[]] | sort_by(.settings.challenge_id, -.details.num_solutions)')
declare -A SOLUTIONS_COUNT
for BENCHMARK in $(echo $BENCHMARKS | jq -c '.[]'); do
ID=$(echo $BENCHMARK | jq -r '.id')
SETTINGS=$(echo $BENCHMARK | jq -c '.settings')
CHALLENGE_ID=$(echo $BENCHMARK | jq -r '.settings.challenge_id')
NUM_SOLUTIONS=$(echo $BENCHMARK | jq -r '.details.num_solutions')
printf "ID: %-38s #Solutions: %-5s Settings: %-50s \n" "$ID" "$NUM_SOLUTIONS" "$SETTINGS"
SOLUTIONS_COUNT["$CHALLENGE_ID"]=$(( ${SOLUTIONS_COUNT["$CHALLENGE_ID"]:-0} + NUM_SOLUTIONS ))
done
echo "Total solutions by Challenge ID:"
for CHALLENGE_ID in "${!SOLUTIONS_COUNT[@]}"; do
echo "Challenge ID: $CHALLENGE_ID, Total Solutions: ${SOLUTIONS_COUNT[$CHALLENGE_ID]}"
done