mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
testdata.convert
This commit is contained in:
1 parent
26f780ddee
commit
0d7d6ea12a
15 files changed
+199
-127
No files matched your search
@@ -0,0 +1,17 @@
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
function convert(ini) {
|
||||
const f = ini.split('\n');
|
||||
const count = f[0];
|
||||
const res = { cases: [] };
|
||||
for (let i = 1; i <= count; i++) {
|
||||
const [input, output, time, score, memory] = f[i].split('|');
|
||||
const cur = { input, output, score };
|
||||
if (parseInt(time) !== 1) cur.time = `${time}s`;
|
||||
if (!Number.isNaN(parseInt(memory))) cur.memory = parseInt(memory) / 1024;
|
||||
res.cases.push(cur);
|
||||
}
|
||||
return yaml.safeDump(res);
|
||||
}
|
||||
|
||||
global.Hydro.lib['testdata.convert.ini'] = module.exports = convert;
|
||||
Reference in new issue
Block a user