Skip to content

Commit d1d2b1b

Browse files
authored
update checker script
1 parent 8ee956d commit d1d2b1b

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
## Checker
55

6-
To utilize the custom checker, please ensure that the manifest.yaml file does not include the checker attribute.
6+
To utilize the custom checker, please ensure that the `manifest.yaml` file does not include the checker attribute.
77

8-
The custom checker, which should be named checker, must be stored in the main directory of the task.
8+
The custom checker, which should be named `checker`, must be stored in the main directory of the task.
99

1010
The checker script must be provided by the user and takes in the following command-line arguments:
1111

@@ -63,17 +63,20 @@ If you intend to utilize C++ code without the need for compilation, you can inco
6363

6464
FILENAME="checker.cpp"
6565

66-
OUTPUT="output"
66+
BINNAME="output"
6767

6868
DIR="$( cd "$( dirname "$0" )" && pwd )"
6969

70-
CHECKER="${DIR}/${OUTPUT}"
70+
CHECKER="${DIR}/${BINNAME}"
7171

72-
if ! test -f "${CHECKER}"; then
73-
( cd "${DIR}" && g++ -std=c++11 -O2 -Wall -Wextra -pedantic -o "${OUTPUT}" "${FILENAME}")
72+
LAST_CHECKER="$(stat -c%Y ${DIR}/${FILENAME})"
73+
LAST_BIN="$(stat -c%Y ${CHECKER} 2> /dev/null)"
74+
75+
if [[ ! -f "${CHECKER}" ]] || [[ $LAST_CHECKER -ge $LAST_BIN ]]; then
76+
( cd "${DIR}" && g++ -std=c++11 -O2 -Wall -Wextra -pedantic -o "${BINNAME}" "${FILENAME}")
7477
fi
7578

76-
( cd "${DIR}" && "./${OUTPUT}" $1 $2 $3 )
79+
( cd "${DIR}" && "./${BINNAME}" $1 $2 $3 )
7780
```
7881

7982
Additionally, remember to place the `checker.cpp` file inside the main directory of the task.
@@ -84,10 +87,10 @@ Default checkers are provided with the grader that can easily be used by specify
8487

8588
Each default checker will split output into tokens as follows:
8689

87-
- ncmp: single or more 64-bit integers, ignores whitespaces
88-
- wcmp: sequence of tokens
89-
- nyesno: single or more yes/no tokens, case insensitive
90-
- lcmp: lines, ignores whitespaces
91-
- fcmp: lines, doesn't ignore whitespaces
92-
- rcmp6: single or more floating point numbers, maximum error $10^{-6}$
93-
- rcmp9: single or more floating point numbers, maximum error $10^{-9}$
90+
- `ncmp`: single or more 64-bit integers, ignores whitespaces
91+
- `wcmp`: sequence of tokens
92+
- `nyesno`: single or more yes/no tokens, case insensitive
93+
- `lcmp`: lines, ignores whitespaces
94+
- `fcmp`: lines, doesn't ignore whitespaces
95+
- `rcmp6`: single or more floating point numbers, maximum error $10^{-6}$
96+
- `rcmp9`: single or more floating point numbers, maximum error $10^{-9}$

0 commit comments

Comments
 (0)