Browse Source

Improve automatic testcases sorting

pull/6/head
Pisces000221 7 years ago
parent
commit
d22b67f1eb
  1. 10
      utility.js

10
utility.js

@ -245,14 +245,8 @@ module.exports = {
res[0].type = 'sum'; res[0].type = 'sum';
res[0].score = 100; res[0].score = 100;
res[0].cases.sort((a, b) => { res[0].cases.sort((a, b) => {
function getLastInteger(s) { let extractNumerals = (s) => (s.match(/\d+/g) || []).map((x) => parseInt(x)).concat(s);
let re = /(\d+)\D*$/; return extractNumerals(a.input) < extractNumerals(b.input) ? -1 : +1;
let x = re.exec(s);
if (x) return parseInt(x[1]);
else return -1;
}
return getLastInteger(a.input) - getLastInteger(b.input);
}); });
res.spj = list.some(s => s.startsWith('spj_')); res.spj = list.some(s => s.startsWith('spj_'));

Loading…
Cancel
Save