mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
727 B
69 lines
727 B
#!/usr/bin/env bash |
|
|
|
set -euo pipefail |
|
IFS=' |
|
' |
|
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) |
|
|
|
challenge() { |
|
args=${@:1:$#-1} |
|
input="${@: -1}" |
|
|
|
submitted=$( |
|
./student/joker-num.sh $args <<EOF |
|
$input |
|
EOF |
|
) |
|
expected=$( |
|
./solutions/joker-num.sh $args <<EOF |
|
$input |
|
EOF |
|
) |
|
diff <(echo "$submitted") <(echo "$expected") |
|
} |
|
|
|
# Good input, win |
|
challenge 50 "1 |
|
100 |
|
49 |
|
51 |
|
50 |
|
" |
|
|
|
# Good input, lose |
|
challenge 50 "10 |
|
20 |
|
30 |
|
40 |
|
41 |
|
42 |
|
" |
|
|
|
# Bad arguments |
|
challenge "10" |
|
|
|
# Bad arguments |
|
challenge 0 "10" |
|
|
|
# Bad arguments |
|
challenge 101 "10" |
|
|
|
# Bad arguments |
|
challenge -20 "10" |
|
|
|
# Bad arguments |
|
challenge aa "10" |
|
|
|
# Handle bad input |
|
challenge 78 "10 |
|
aa |
|
|
|
|
|
3000 |
|
-10 |
|
0 |
|
0 |
|
40 |
|
80 |
|
79 |
|
78"
|
|
|