Update the script so that it doesn't need a solution

This commit is contained in:
Segcolt 2024-10-14 23:27:27 -03:00
parent ad5aedd454
commit 41245cae8f

8
run.sh
View File

@ -15,19 +15,23 @@ if [[ -z $SOLUTIONS_FILE ]]; then
fi
declare -A solutions
while read line; do
if [[ -f "$SOLUTIONS_FILE" ]]; then
while read line; do
solutions[$(awk '{print $1}' <<< "$line")]=$(awk '{print $2}' <<< "$line")
done < "$SOLUTIONS_FILE"
done < "$SOLUTIONS_FILE"
fi
for file in $(find "$TEST_FOLDER" -type f); do
echo "Arquivo de teste: $file"
res=$("$EXEC" -i -c < "$file" | awk '{print $4}')
optimal=${solutions[$(basename "$file")]}
echo "Resultado do programa: ${res}"
if [[ ! -z $optimal ]]; then
echo "Resultado ótimo: ${optimal}"
if [[ $res = $optimal ]]; then
echo "Resultado ótimo!"
else
echo "Diferença de $(bc <<< "${res} - ${optimal}")"
fi
fi
done