From 41245cae8f7ec60cf8c851ff9decdd1fe8d7a114 Mon Sep 17 00:00:00 2001 From: Segcolt <9hmbzr275@mozmail.com> Date: Mon, 14 Oct 2024 23:27:27 -0300 Subject: [PATCH] Update the script so that it doesn't need a solution --- run.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/run.sh b/run.sh index b15392f..4a40390 100755 --- a/run.sh +++ b/run.sh @@ -15,19 +15,23 @@ if [[ -z $SOLUTIONS_FILE ]]; then fi declare -A solutions -while read line; do - solutions[$(awk '{print $1}' <<< "$line")]=$(awk '{print $2}' <<< "$line") -done < "$SOLUTIONS_FILE" +if [[ -f "$SOLUTIONS_FILE" ]]; then + while read line; do + solutions[$(awk '{print $1}' <<< "$line")]=$(awk '{print $2}' <<< "$line") + 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}" - echo "Resultado ótimo: ${optimal}" - if [[ $res = $optimal ]]; then - echo "Resultado ótimo!" - else - echo "Diferença de $(bc <<< "${res} - ${optimal}")" + 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