judge_system 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f17bd691aafc0327392df7b6ccd019c943b18e3
4
- data.tar.gz: 72e7aa6563ac2466f5fb379f2b611991e7a7081f
3
+ metadata.gz: a45139d0e2832eccef34a7f8c6d71fa20de7f9a2
4
+ data.tar.gz: 7e10badc069a5be4e44fda91bfa880eb0467d8cb
5
5
  SHA512:
6
- metadata.gz: c36e4f011f51c1dbc84a11c4747d48709d83d2e78b1efdfb63f5c04a8b625227c4d750761d8343269f3053232d30bd0bd43778b169892a21b8d7b185e2ccbd86
7
- data.tar.gz: 7f58b8f5b213d9b27c5a90bed6657e3646a0794c2c636d96e34b7e76dc5b1aeb72dd5c3ecafd99649903ab20cc6d03a6da6bfbe5f3b5e4e5895afcc8ba5c8b84
6
+ metadata.gz: 9721286ffcafc49c6fa33019743c541d80f7515dae8012993c10a8a30b2413829b06e2100a4a52bdc586470d9654ef8c87e704d7f50fca1348001d1948e9e66b
7
+ data.tar.gz: 29368cebb9d27e02998438d20b62a7ae29524bf5fd41f01feeb01fe62ab8a46f982a1b4cf9f6843db096b29c58856aae4029d1fbe4b712e52852bbc062d899d1
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /lib/old_compile_systems/
data/README.md CHANGED
@@ -31,7 +31,7 @@ require 'judge_system'
31
31
  JudgeSystem.judge_result lang: (string text), code: (string text), answer: (string text), stdin: (string text), time: (num sec)
32
32
 
33
33
  #Lang is the extension of languages (example: c is 'c', c++ is 'cpp', ruby is 'rb', go is 'go', python3 is 'py').
34
- #You can't use more than 1M byte code, input, answer.
34
+ #You can't use more than 2M byte code and input.
35
35
 
36
36
  ```
37
37
 
@@ -0,0 +1,22 @@
1
+ require 'zlib'
2
+
3
+ File.open("./main.c", "w") do |file|
4
+ loop{
5
+ str = gets.chomp.to_s
6
+ break if str == "<$><*><$>"
7
+ file.puts str
8
+ }
9
+ file.close
10
+ end
11
+
12
+ File.open("./test.in", "w") do |file|
13
+ loop{
14
+ str = gets.chomp.to_s
15
+ break if str == "<$><*><$>"
16
+ file.puts Zlib::Inflate.inflate(str)
17
+ }
18
+ file.close
19
+ end
20
+ time = gets
21
+ system "/opt/wandbox/gcc-head/bin/gcc main.c -o main -O2"
22
+ system "timeout -s 9 " + time + " ./main < test.in"
@@ -0,0 +1,22 @@
1
+ require 'zlib'
2
+
3
+ File.open("./main.cpp", "w") do |file|
4
+ loop{
5
+ str = gets.chomp.to_s
6
+ break if str == "<$><*><$>"
7
+ file.puts str
8
+ }
9
+ file.close
10
+ end
11
+
12
+ File.open("./test.in", "w") do |file|
13
+ loop{
14
+ str = gets.chomp.to_s
15
+ break if str == "<$><*><$>"
16
+ file.puts Zlib::Inflate.inflate(str)
17
+ }
18
+ file.close
19
+ end
20
+ time = gets
21
+ system "/opt/wandbox/gcc-head/bin/g++ main.cpp -o main -O2"
22
+ system "timeout -s 9 " + time + " ./main < test.in"
@@ -0,0 +1,21 @@
1
+ require 'zlib'
2
+
3
+ File.open("./main.go", "w") do |file|
4
+ loop{
5
+ str = gets.chomp.to_s
6
+ break if str == "<$><*><$>"
7
+ file.puts str
8
+ }
9
+ file.close
10
+ end
11
+
12
+ File.open("./test.in", "w") do |file|
13
+ loop{
14
+ str = gets.chomp.to_s
15
+ break if str == "<$><*><$>"
16
+ file.puts Zlib::Inflate.inflate(str)
17
+ }
18
+ file.close
19
+ end
20
+ time = gets
21
+ system "timeout -s 9 " + time + " /opt/wandbox/go-head/bin/go run main.go < test.in"
@@ -0,0 +1,21 @@
1
+ require 'zlib'
2
+
3
+ File.open("./main.py", "w") do |file|
4
+ loop{
5
+ str = gets.chomp.to_s
6
+ break if str == "<$><*><$>"
7
+ file.puts str
8
+ }
9
+ file.close
10
+ end
11
+
12
+ File.open("./test.in", "w") do |file|
13
+ loop{
14
+ str = gets.chomp.to_s
15
+ break if str == "<$><*><$>"
16
+ file.puts Zlib::Inflate.inflate(str)
17
+ }
18
+ file.close
19
+ end
20
+ time = gets
21
+ system "timeout -s 9 " + time + " /opt/wandbox/cpython-head/bin/python3 main.py < test.in"
@@ -0,0 +1,21 @@
1
+ require 'zlib'
2
+
3
+ File.open("./main.rb", "w") do |file|
4
+ loop{
5
+ str = gets.chomp.to_s
6
+ break if str == "<$><*><$>"
7
+ file.puts str
8
+ }
9
+ file.close
10
+ end
11
+
12
+ File.open("./test.in", "w") do |file|
13
+ loop{
14
+ str = gets.chomp.to_s
15
+ break if str == "<$><*><$>"
16
+ file.puts Zlib::Inflate.inflate(str)
17
+ }
18
+ file.close
19
+ end
20
+ time = gets
21
+ system "timeout -s 9 " + time + " /opt/wandbox/ruby-head/bin/ruby main.rb < test.in"
@@ -1,3 +1,3 @@
1
1
  module JudgeSystem
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/judge_system.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require "judge_system/version"
2
+ require 'zlib_input'
2
3
  require "net/http"
3
4
  require "uri"
4
5
  require "json"
5
6
  require 'timeout'
6
7
  require 'pathname'
7
-
8
8
  module JudgeSystem
9
9
  class WandBox
10
10
 
@@ -16,7 +16,7 @@ module JudgeSystem
16
16
  }
17
17
  uri = URI.parse("http://melpon.org/wandbox/api/compile.json")
18
18
  request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-type" => "application/json" },)
19
- request.body = body.to_json
19
+ request.body = JSON.generate body
20
20
  http = Net::HTTP.new(uri.host, uri.port)
21
21
  http.start do |http|
22
22
  response = http.request(request)
@@ -26,14 +26,15 @@ module JudgeSystem
26
26
 
27
27
  def self.run lang, code, input, time
28
28
  path = File.expand_path('../', __FILE__ )
29
- sys = File.open("#{path}/compile_systems/#{lang}_system.cpp", "r").read
29
+ sys = File.open("#{path}/compile_systems/#{lang}_system.rb", "r").read
30
30
  data = nil
31
31
  spliter = "\n<$><*><$>\n"
32
+ input = ZlibInput.zlib(input)
32
33
  stdin = code + spliter + input + spliter + ("%f" % time)
33
34
  begin
34
- data = compile( compiler: "gcc-head", code: sys, stdin: stdin )
35
- rescue
36
- return 'RE'
35
+ data = compile( compiler: "ruby-head", code: sys, stdin: stdin )
36
+ rescue
37
+ return "RE"
37
38
  end
38
39
  error = data["program_error"]
39
40
  result = data["program_output"]
@@ -65,7 +66,7 @@ module JudgeSystem
65
66
  end
66
67
  end
67
68
 
68
- def judge_result lang: "", code: "" , answer: "", stdin: "", time: 100
69
+ def judge_result lang: "", code: "" , answer: "", stdin: "", time: 20
69
70
  WandBox.judge lang, code, answer, stdin, time
70
71
  end
71
72
 
data/lib/zlib_input.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'zlib'
2
+
3
+ module ZlibInput
4
+ def zlib input
5
+ Zlib::Deflate.deflate(input,Zlib::BEST_SPEED)
6
+ end
7
+ module_function :zlib
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judge_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - getty104
@@ -71,15 +71,14 @@ files:
71
71
  - bin/console
72
72
  - bin/setup
73
73
  - judge_system.gemspec
74
- - lib/compile_systems/c_system.cpp
75
- - lib/compile_systems/cpp_system.cpp
76
- - lib/compile_systems/go_system.cpp
77
- - lib/compile_systems/java_system.cpp
78
- - lib/compile_systems/py_system.cpp
79
- - lib/compile_systems/rb_system.cpp
74
+ - lib/compile_systems/c_system.rb
75
+ - lib/compile_systems/cpp_system.rb
76
+ - lib/compile_systems/go_system.rb
77
+ - lib/compile_systems/py_system.rb
78
+ - lib/compile_systems/rb_system.rb
80
79
  - lib/judge_system.rb
81
80
  - lib/judge_system/version.rb
82
- - test.rb
81
+ - lib/zlib_input.rb
83
82
  - wercker.yml
84
83
  homepage: https://github.com/getty104/judge_system
85
84
  licenses:
@@ -1,29 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- char command[1024];
6
-
7
- int main(int argc, char const *argv[])
8
- {
9
- ofstream ofs;
10
- ofs.open("main.c",ios::binary);
11
- string buf;
12
- string splitter="<$><*><$>";
13
- string time;
14
- while(getline(cin,buf)){
15
- if(buf==splitter)break;
16
- ofs<<buf<<endl;
17
- }
18
- ofs.close();
19
- ofs.open("test.in",ios::binary);
20
- while(getline(cin,buf)){
21
- if(buf==splitter)break;
22
- ofs<<buf<<endl;
23
- }
24
- ofs.close();
25
- cin>>time;
26
- system("/opt/wandbox/gcc-head/bin/gcc main.c -o main -O2");
27
- system(("timeout -s 9 " + time + " ./main < test.in").c_str());
28
- return 0;
29
- }
@@ -1,29 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- char command[1024];
6
-
7
- int main(int argc, char const *argv[])
8
- {
9
- ofstream ofs;
10
- ofs.open("main.cpp",ios::binary);
11
- string buf;
12
- string splitter="<$><*><$>";
13
- string time;
14
- while(getline(cin,buf)){
15
- if(buf==splitter)break;
16
- ofs<<buf<<endl;
17
- }
18
- ofs.close();
19
- ofs.open("test.in",ios::binary);
20
- while(getline(cin,buf)){
21
- if(buf==splitter)break;
22
- ofs<<buf<<endl;
23
- }
24
- ofs.close();
25
- cin>>time;
26
- system("/opt/wandbox/gcc-head/bin/g++ main.cpp -o main -O2");
27
- system(("timeout -s 9 " + time + " ./main < test.in").c_str());
28
- return 0;
29
- }
@@ -1,28 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- char command[1024];
6
-
7
- int main(int argc, char const *argv[])
8
- {
9
- ofstream ofs;
10
- ofs.open("main.go",ios::binary);
11
- string buf;
12
- string splitter="<$><*><$>";
13
- string time;
14
- while(getline(cin,buf)){
15
- if(buf==splitter)break;
16
- ofs<<buf<<endl;
17
- }
18
- ofs.close();
19
- ofs.open("test.in",ios::binary);
20
- while(getline(cin,buf)){
21
- if(buf==splitter)break;
22
- ofs<<buf<<endl;
23
- }
24
- ofs.close();
25
- cin>>time;
26
- system(("timeout -s 9 " + time + " /opt/wandbox/go-head/bin/go run main.go < test.in ").c_str());
27
- return 0;
28
- }
@@ -1,88 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- int main(int argc, char const *argv[])
6
- {
7
- ofstream ofs;
8
- ofs.open("Main.java",ios::binary);
9
- string buf;
10
- while(getline(cin,buf)){
11
- if(buf=="<$><*><$>")break;
12
- ofs<<buf<<endl;
13
- }
14
- ofs.close();
15
- ofs.open("test.in",ios::binary);
16
- while(getline(cin,buf)){
17
- ofs<<buf<<endl;
18
- }
19
- ofs.close();
20
- system("/opt/wandbox/openjdk-head/bin/javac Main.java");
21
- system("/usr/bin/time -f '%U' /opt/wandbox/openjdk-head/bin/java Main < test.in");
22
- return 0;
23
- }
24
-
25
-
26
-
27
-
28
- /*
29
- import java.util.*;
30
- import java.io.*;
31
- class Career{
32
- public static void main(String[] args){
33
-
34
- BufferedReader sc;
35
- File code;
36
- File stdin;
37
- FileWriter pw1;
38
- FileWriter pw2;
39
- String str;
40
- BufferedReader br1;
41
- BufferedReader br2;
42
- Runtime r;
43
- Runtime rr;
44
- InputStream compile;
45
- InputStream run;
46
-
47
- try{
48
- sc = new BufferedReader(new InputStreamReader(System.in));
49
- code = new File("Main.java");
50
- code.createNewFile();
51
- code = new File("Main.java");
52
- stdin = new File("test.in");
53
- stdin.createNewFile();
54
- stdin = new File("test.in");
55
- pw1 = new FileWriter(code, true);
56
- pw2 = new FileWriter(stdin, true);
57
- while(true){
58
- str = sc.readLine();
59
- if(str.equals("<$><*><$>")){
60
- break;
61
- }
62
- pw1.write(str);
63
- }
64
- pw1.close();
65
-
66
-
67
- while((str = sc.readLine()) != null){
68
- pw2.write(str);
69
- }
70
- pw2.close();
71
- r = Runtime.getRuntime();
72
- rr = Runtime.getRuntime();
73
- compile = r.exec("/opt/wandbox/openjdk-head/bin/javac Main.java").getInputStream();
74
- run = rr.exec("/opt/wandbox/openjdk-head/bin/java Main < test.in").getInputStream();
75
- br1 = new BufferedReader(new InputStreamReader(compile));
76
- br2 = new BufferedReader(new InputStreamReader(run));
77
- while ((str = br1.readLine()) != null) {
78
- System.out.println(str);
79
- }
80
- while ((str = br2.readLine()) != null) {
81
- System.out.println(str);
82
- }
83
- }catch(Exception e ){
84
- e.printStackTrace();
85
- }
86
- }
87
- }
88
- */
@@ -1,28 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- char command[1024];
6
-
7
- int main(int argc, char const *argv[])
8
- {
9
- ofstream ofs;
10
- ofs.open("main.py",ios::binary);
11
- string buf;
12
- string splitter="<$><*><$>";
13
- string time;
14
- while(getline(cin,buf)){
15
- if(buf==splitter)break;
16
- ofs<<buf<<endl;
17
- }
18
- ofs.close();
19
- ofs.open("test.in",ios::binary);
20
- while(getline(cin,buf)){
21
- if(buf==splitter)break;
22
- ofs<<buf<<endl;
23
- }
24
- ofs.close();
25
- cin>>time;
26
- system(("timeout -s 9 " + time + " /opt/wandbox/cpython-head/bin/python3 main.py < test.in").c_str());
27
- return 0;
28
- }
@@ -1,28 +0,0 @@
1
- #include <iostream>
2
- #include <fstream>
3
- using namespace std;
4
-
5
- char command[1024];
6
-
7
- int main(int argc, char const *argv[])
8
- {
9
- ofstream ofs;
10
- ofs.open("main.rb",ios::binary);
11
- string buf;
12
- string splitter="<$><*><$>";
13
- string time;
14
- while(getline(cin,buf)){
15
- if(buf==splitter)break;
16
- ofs<<buf<<endl;
17
- }
18
- ofs.close();
19
- ofs.open("test.in",ios::binary);
20
- while(getline(cin,buf)){
21
- if(buf==splitter)break;
22
- ofs<<buf<<endl;
23
- }
24
- ofs.close();
25
- cin>>time;
26
- system(("timeout -s 9 " + time + " /opt/wandbox/ruby-head/bin/ruby main.rb < test.in").c_str());
27
- return 0;
28
- }
data/test.rb DELETED
File without changes