Scripts for testing programming problem solutions.
Will compile and run the source (C++17, Java or Python3).
The memory-limit is in MBs (default: 256).
If input.txt exists, will do:
rr solution <input.txt >stdout.txtand then if output.txt exists, will do:
diff stdout.txt output.txtOtherwise, if tests.txt exists, will extract each test case into input.txt and output.txt, and will do:
tt solutionThe tests.txt should look like:
input:
...
output:
...
input:
...
output:
...
Tip: the following bookmarklet scrapes sample tests from codeforces.com problem statement and downloads them in a tests.txt file:
javascript:
var inputs = document.querySelectorAll('.input pre');
var outputs = document.querySelectorAll('.output pre');
var data = '';
for (var i = 0; i < inputs.length; i++) {
data += 'input:\n' + inputs[i].innerText.replace(/\n*$/, '\n');
data += 'output:\n' + outputs[i].innerText.replace(/\n*$/, '\n\n');
}
var a = document.createElement('a');
a.setAttribute('href', 'data:text/plain,' + encodeURIComponent(data));
a.setAttribute('download', 'tests.txt');
document.body.appendChild(a);
a.click();Will do:
while true; do
rr generator >input.txt
tt solution
doneWill do:
while true; do
rr generator >input.txt
rr solver <input.txt >output.txt
tt solution
doneWill compile the source (C++17) and start gdb.