Module: CodeforcesClient
- Defined in:
- lib/codeforces_client.rb,
lib/codeforces_client/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.client(contestID, problemIndex) ⇒ Object
Your code goes here…
- .run_sample_test(problem_index) ⇒ Object
Class Method Details
.client(contestID, problemIndex) ⇒ Object
Your code goes here…
9 10 11 |
# File 'lib/codeforces_client.rb', line 9 def self.client( contestID, problemIndex) Arena.new(contestID, problemIndex) end |
.run_sample_test(problem_index) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/codeforces_client.rb', line 13 def self.run_sample_test(problem_index) test_file = File.join Dir.pwd, problem_index+'_sampleTest.txt' if File.exist?(test_file) myruby = File.join Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'] myscript = File.join Dir.pwd, problem_index+'.rb' tests = File.read(test_file).gsub(/\r\n?/, "\n").strip.split("Sample test\n")[1..-1] tests.map{|e| e.strip.split "\n\n"}.each_with_index do |each, index| Open3.popen3(myruby,myscript) do |sin, sout| sin.puts each[0] res = sout.read.strip if each[1] != res print "FAIL test case:#{index}: \n" print "***Expected: #{each[1]}\n" print "***Received: #{res}\n" else puts "Test Case#{index} PASSED" end end end else puts "there is no #{problem_index}_sampleTest.txt file, please check it" end end |