When solving the AtCoder problem and checking the operation with the input / output sample test Copying by hand and checking the output ... It takes a lot of time to repeat. In particular, it affects the correct answer time for 100-200 points questions.
To reduce this, I created a tool that automatically tests by giving a set of input / output data.
https://github.com/mui-nyan/atcoder_testtool
.bashrc
etc., or add ʻatcoder_testtool` to PATH.actest_python() {
bash ~/Documents/dev/atcoder_testtool/actest_python.sh $1 $2
}
Create a data file in the same directory as the source file you want to test. Here, the file name is ʻinput. The format of the data file is as follows:
input --- output ===` is repeated.
Input 1
---
Output 1
===
Input 2
---
Output 2
===
(===
is required after the last output)
If you execute ʻactest_python` and give the source file name and data file as arguments, it will be tested in order.
$ actest_python B.py input
AC 91ms Expect: 2 Actual: 2
AC 92ms Expect: 0 Actual: 0
AC 91ms Expect: 5 Actual: 5
This is a display sample when the answer is incorrect or the time limit is exceeded. The time limit is fixed at 2 seconds.
$ actest_python B.py input
WA 96ms Expect: 2 Actual: 3
TLE 2192ms Expect: 0 Actual: 0
AC 91ms Expect: 5 Actual: 5
The test is easy, but creating the data file is still a hassle, so I also made a tool to help create the data file.
It's also included on GitHub above, but this is it.
javascript: (function(){ let ans = ""; let i=0; while($(`.lang-ja #pre-sample${i}`).length > 0) { const input = $(`#pre-sample${i}`).html().trim(); const expect = $(`#pre-sample${i+1}`).html().trim(); ans += input + "\n---\n" + expect + "\n===\n"; i += 2; } console.log(ans); navigator.clipboard.writeText(ans); })();
Bookmark this ...
Run on the question page ...
When pasted,
You can create a data file!
happy!
Recommended Posts