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

20
run.sh
View File

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