-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade
More file actions
executable file
·36 lines (32 loc) · 953 Bytes
/
grade
File metadata and controls
executable file
·36 lines (32 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
printf "\n\n### Multiply ###\n\n"
exe() { printf "\n"; echo "! ${@/eval/}" ; "$@" ; }
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
rm -f main.exe
exe make
ERROR=$?
if [ $ERROR -eq 0 ]; then
printf "\n! run on inputs\n"
let right=0
let wrong=0
for inputFilename in $( ls input-*.io ); do
expectedFilename="${inputFilename/input-/output-}"
caseName="${inputFilename/input-/}"
caseName="${caseName/[.]io/}"
userOutput=$( ./main.exe < $inputFilename )
trueOutput=$( cat "$expectedFilename" )
printf "\n$caseName:\n * Your output=$userOutput\n * True output=$trueOutput\n"
if [ "$userOutput" == "$trueOutput" ]; then
let right++
else
let wrong++
fi
done
printf "\n*** Right: $right. Wrong: $wrong. ***\n"
let "grade = right * 100 / (right + wrong)"
else
grade=0
fi
printf "\n$grade [signature]\n"
rm -f main.exe