judge_system 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/judge_system.rb +36 -44
- data/lib/judge_system/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bef44e28ea19331d8b7fe9e3beaff4f066ffabb
|
4
|
+
data.tar.gz: 11a5efed6d3535483c702248bef664eec7b6d4ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b2c400478b053ae0f2a6a55980e89dd92990580c96a103c7650c16ea8a518b4922022cd9e60f4f6d9f16326bc727059d21dfe33aac3b615815f4b9ffa7fb21f
|
7
|
+
data.tar.gz: '06863728db1303afa46c1dd6fa902fb73254067ea578ac90c41c2873c0e3870403586f6a30e18a280a8b618c0dfe0e141bc7061ccbaffc316817ff08a69437c7'
|
data/lib/judge_system.rb
CHANGED
@@ -6,45 +6,32 @@ require 'timeout'
|
|
6
6
|
require 'pathname'
|
7
7
|
|
8
8
|
module JudgeSystem
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-type" => "application/json" },)
|
25
|
-
request.body = body.to_json
|
26
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
27
|
-
|
28
|
-
|
29
|
-
http.start do |http|
|
30
|
-
response = http.request(request)
|
31
|
-
JSON.parse(response.body)
|
32
|
-
end
|
33
|
-
|
9
|
+
class WandBox
|
10
|
+
|
11
|
+
def self.compile compiler: "", code: "", stdin: ""
|
12
|
+
body = {
|
13
|
+
code: code,
|
14
|
+
compiler: compiler,
|
15
|
+
stdin: stdin,
|
16
|
+
}
|
17
|
+
uri = URI.parse("http://melpon.org/wandbox/api/compile.json")
|
18
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-type" => "application/json" },)
|
19
|
+
request.body = body.to_json
|
20
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
21
|
+
http.start do |http|
|
22
|
+
response = http.request(request)
|
23
|
+
JSON.parse(response.body)
|
34
24
|
end
|
35
|
-
module_function :compile
|
36
25
|
end
|
37
|
-
end
|
38
26
|
|
39
|
-
|
40
|
-
def run lang, code, input, time
|
27
|
+
def self.run lang, code, input, time
|
41
28
|
path = File.expand_path('../', __FILE__ )
|
42
29
|
sys = File.open("#{path}/compile_systems/#{lang}_system.cpp", "r").read
|
43
30
|
data = nil
|
44
31
|
spliter = "\n<$><*><$>\n"
|
45
32
|
stdin = code + spliter + input + spliter + time.to_s
|
46
33
|
begin
|
47
|
-
data =
|
34
|
+
data = compile( compiler: "gcc-head", code: sys, stdin: stdin )
|
48
35
|
rescue
|
49
36
|
return 'RE'
|
50
37
|
end
|
@@ -58,23 +45,28 @@ module JudgeSystem
|
|
58
45
|
return result
|
59
46
|
end
|
60
47
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
return 'RE'
|
70
|
-
else
|
71
|
-
result = output == answer
|
72
|
-
if result
|
73
|
-
return 'AC'
|
48
|
+
private_class_method :compile, :run
|
49
|
+
public
|
50
|
+
def self.judge lang, code , answer, stdin, time
|
51
|
+
output = run lang, code, stdin, time
|
52
|
+
if output == 'TLE'
|
53
|
+
return 'TLE'
|
54
|
+
elsif output == 'RE'
|
55
|
+
return 'RE'
|
74
56
|
else
|
75
|
-
|
57
|
+
result = output == answer
|
58
|
+
if result
|
59
|
+
return 'AC'
|
60
|
+
else
|
61
|
+
return 'WA'
|
62
|
+
end
|
76
63
|
end
|
77
64
|
end
|
78
65
|
end
|
66
|
+
|
67
|
+
def judge_result lang: "", code: "" , answer: "", stdin: "", time: 100
|
68
|
+
WandBox.judge lang, code, answer, stdin, time
|
69
|
+
end
|
70
|
+
|
79
71
|
module_function :judge_result
|
80
72
|
end
|
data/lib/judge_system/version.rb
CHANGED