MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / convertIniConfig

Function convertIniConfig

packages/common/subtask.ts:3–20  ·  view source on GitHub ↗
(ini: string)

Source from the content-addressed store, hash-verified

1import { parseMemoryMB, parseTimeMS, sortFiles } from '@hydrooj/utils/lib/common';
2
3export function convertIniConfig(ini: string) {
4 const f = ini.split('\n');
5 const count = Number.parseInt(f[0], 10);
6 const res = { subtasks: [] };
7 for (let i = 1; i <= count; i++) {
8 if (!f[i]?.trim()) throw new Error('Testdata count incorrect.');
9 const [input, output, time, score, memory] = f[i].split('|');
10 const cur = {
11 cases: [{ input, output }],
12 score: Number.parseInt(score, 10),
13 time: `${time}s`,
14 memory: '256m',
15 };
16 if (!Number.isNaN(Number.parseInt(memory, 10))) cur.memory = `${Math.floor(Number.parseInt(memory, 10) / 1024)}m`;
17 res.subtasks.push(cur);
18 }
19 return res;
20}
21
22interface MatchRule {
23 regex: RegExp;

Callers 1

readCasesFunction · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected