lib/judge_system.rb in judge_system-1.7.3 vs lib/judge_system.rb in judge_system-1.7.4

- old
+ new

@@ -20,38 +20,45 @@ response = http.request(request) JSON.parse(response.body) end def self.run(lang, code, input, time) - path = File.expand_path('../', __FILE__) + path = File.expand_path(__dir__) sys = File.open("#{path}/compile_systems/#{lang}_system.rb", 'r').read - data = nil spliter = "\n<$><*><$>\n" - stdin = BZip2Input.compress(code + spliter + input + spliter + format('%f', time)) + stdin = BZip2Input.compress(code + spliter + input + spliter + format('%<time>f', time: time)) + begin data = compile(compiler: 'ruby-head', code: sys, stdin: stdin) - rescue + rescue StandardError return 'RE' end + error = data['program_error'] result = data['program_output'] - return 'TLE' if error == "Killed\n" - return 'RE' if result.nil? && error + + if error == "Killed\n" + result = 'TLE' + elsif result.nil? && error + result = 'RE' + end result end private_class_method :compile, :run def self.judge(lang, code, answer, stdin, time) output = run(lang, code, stdin, time) - return 'TLE' if output == 'TLE' - return 'RE' if output == 'RE' - output == answer ? 'AC' : 'WA' + if %w[TLE RE].include?(output) + output + else + output == answer ? 'AC' : 'WA' + end end end + module_function + def judge_result(lang: '', code: '', answer: '', stdin: '', time: 20) WandBox.judge(lang, code, answer, stdin, time) end - - module_function :judge_result end