-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluate.js
35 lines (29 loc) · 1.18 KB
/
evaluate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
process.stdin.on("data", function(data) {
const fs = require("fs");
const path = require("path")
const Judge = require("./judge.js").Judge;
// parse JSON with configuration settings from stdin
const config = JSON.parse(data);
// extract configuration settings
const resourcesDir = config["resources"];
const sourceFile = config["source"];
const timeLimit = config["time_limit"];
const memoryLimit = config["memory_limit"];
const naturalLanguage = config["natural_language"];
const programmingLanguage = config["programming_language"];
// process tests
const judge = new Judge(
path.join(resourcesDir, "tests.js"),
{
// convert time limit from seconds to millisecond and only consume
// 90% of the available time in order to have some spare time to
// generate the feedback on stdout
time_limit: Math.floor(timeLimit * 900),
memory_limit: memoryLimit,
natural_language: naturalLanguage,
programming_language: programmingLanguage,
}
);
// evaluate tests and output result to stdout
judge.run(sourceFile);
});