Description:
Changed shebang from `/usr/bin/ruby` to `/usr/bin/env ruby`
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r204:6f1fd9fdb8ac - - 7 files changed: 7 inserted, 7 deleted

@@ -1,49 +1,49
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 # new_problem:
3 # new_problem:
4 # * creates a directory for a problem in the current directory,
4 # * creates a directory for a problem in the current directory,
5 # * create standard testcase config file
5 # * create standard testcase config file
6
6
7 require 'erb'
7 require 'erb'
8
8
9 def process_options(options)
9 def process_options(options)
10 i = 2
10 i = 2
11 while i<ARGV.length
11 while i<ARGV.length
12 if ARGV[i]=='-t'
12 if ARGV[i]=='-t'
13 options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
13 options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
14 i += 1
14 i += 1
15 end
15 end
16 if ARGV[i]=='-m'
16 if ARGV[i]=='-m'
17 options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
17 options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
18 i += 1
18 i += 1
19 end
19 end
20 i += 1
20 i += 1
21 end
21 end
22 end
22 end
23
23
24
24
25 puts "This script is out of dated, shall be fixed soon"
25 puts "This script is out of dated, shall be fixed soon"
26 puts "Right now, you can create raw_ev and import"
26 puts "Right now, you can create raw_ev and import"
27 exit(0)
27 exit(0)
28
28
29 GRADER_DIR = File.dirname(__FILE__)
29 GRADER_DIR = File.dirname(__FILE__)
30
30
31 # print usage
31 # print usage
32 if ARGV.length < 2
32 if ARGV.length < 2
33 puts <<USAGE
33 puts <<USAGE
34 using: new_problem problem number_of_testcase [options]
34 using: new_problem problem number_of_testcase [options]
35 * creates a directory for a problem in the current directory,
35 * creates a directory for a problem in the current directory,
36 * create standard testcase config file
36 * create standard testcase config file
37 * options: -t time-limit (in seconds)
37 * options: -t time-limit (in seconds)
38 -m mem-limit (in MB)
38 -m mem-limit (in MB)
39 USAGE
39 USAGE
40 exit(127)
40 exit(127)
41 end
41 end
42
42
43 # processing arguments
43 # processing arguments
44 problem = ARGV[0]
44 problem = ARGV[0]
45 num_testcases = ARGV[1].to_i
45 num_testcases = ARGV[1].to_i
46
46
47 options = {:time_limit => 1, :mem_limit => 16}
47 options = {:time_limit => 1, :mem_limit => 16}
48 process_options(options)
48 process_options(options)
49
49
@@ -1,48 +1,48
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 #
3 #
4 # This is a check script wrapper. It read all required information
4 # This is a check script wrapper. It read all required information
5 # and call a real check script call REAL_CHECK_SCRIPT in directory
5 # and call a real check script call REAL_CHECK_SCRIPT in directory
6 # [problem_home]/script
6 # [problem_home]/script
7 #
7 #
8
8
9 REAL_CHECK_SCRIPT = "<%= script_name %>"
9 REAL_CHECK_SCRIPT = "<%= script_name %>"
10
10
11 # The REAL_CHECK_SCRIPT is called with:
11 # The REAL_CHECK_SCRIPT is called with:
12 #
12 #
13 # (script) <lang> <test-num> <in-file> <out-file> <ans-file> <full-score>
13 # (script) <lang> <test-num> <in-file> <out-file> <ans-file> <full-score>
14 #
14 #
15 # and REAL_CHECK_SCRIPT's output to standard out is redirected to
15 # and REAL_CHECK_SCRIPT's output to standard out is redirected to
16 # 'check_result' as required by normal check script.
16 # 'check_result' as required by normal check script.
17
17
18 problem_home = ENV['PROBLEM_HOME']
18 problem_home = ENV['PROBLEM_HOME']
19 require "#{problem_home}/script/test_dsl.rb"
19 require "#{problem_home}/script/test_dsl.rb"
20
20
21 if ARGV.length < 2
21 if ARGV.length < 2
22 puts "Usage: check <language> <test-number> [<output-file>]"
22 puts "Usage: check <language> <test-number> [<output-file>]"
23 exit(0)
23 exit(0)
24 end
24 end
25
25
26 language = ARGV[0]
26 language = ARGV[0]
27 test_num = ARGV[1].to_i
27 test_num = ARGV[1].to_i
28 if ARGV.length >= 3
28 if ARGV.length >= 3
29 output_file_name = ARGV[2]
29 output_file_name = ARGV[2]
30 else
30 else
31 output_file_name = "output.txt"
31 output_file_name = "output.txt"
32 end
32 end
33
33
34 load "#{problem_home}/test_cases/all_tests.cfg"
34 load "#{problem_home}/test_cases/all_tests.cfg"
35 problem = Problem.get_instance
35 problem = Problem.get_instance
36
36
37 answer_file_name = "#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt"
37 answer_file_name = "#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt"
38 input_file_name = "#{problem_home}/test_cases/#{test_num}/input-#{test_num}.txt"
38 input_file_name = "#{problem_home}/test_cases/#{test_num}/input-#{test_num}.txt"
39
39
40 score = problem.get_score(test_num)
40 score = problem.get_score(test_num)
41
41
42 cmd = "#{problem_home}/script/#{REAL_CHECK_SCRIPT} " +
42 cmd = "#{problem_home}/script/#{REAL_CHECK_SCRIPT} " +
43 "#{language} #{test_num} #{input_file_name} #{output_file_name} " +
43 "#{language} #{test_num} #{input_file_name} #{output_file_name} " +
44 "#{answer_file_name} #{score} > check_result"
44 "#{answer_file_name} #{score} > check_result"
45
45
46 #puts "wrapper-CMD: #{cmd}"
46 #puts "wrapper-CMD: #{cmd}"
47
47
48 system(cmd)
48 system(cmd)
@@ -1,49 +1,49
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 problem_home = ENV['PROBLEM_HOME']
3 problem_home = ENV['PROBLEM_HOME']
4 require "#{problem_home}/script/test_dsl.rb"
4 require "#{problem_home}/script/test_dsl.rb"
5
5
6 if ARGV.length < 2
6 if ARGV.length < 2
7 puts "Usage: check <language> <test-number> [<output-file>]"
7 puts "Usage: check <language> <test-number> [<output-file>]"
8 exit(0)
8 exit(0)
9 end
9 end
10
10
11 language = ARGV[0]
11 language = ARGV[0]
12 test_num = ARGV[1].to_i
12 test_num = ARGV[1].to_i
13 if ARGV.length >= 3
13 if ARGV.length >= 3
14 output_file_name = ARGV[2]
14 output_file_name = ARGV[2]
15 else
15 else
16 output_file_name = "output.txt"
16 output_file_name = "output.txt"
17 end
17 end
18
18
19 load "#{problem_home}/test_cases/all_tests.cfg"
19 load "#{problem_home}/test_cases/all_tests.cfg"
20 problem = Problem.get_instance
20 problem = Problem.get_instance
21
21
22 output_file = File.new(output_file_name, "r")
22 output_file = File.new(output_file_name, "r")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
24 result_file = File.new("check_result", "w")
24 result_file = File.new("check_result", "w")
25
25
26 output_file_content = output_file.read
26 output_file_content = output_file.read
27 answer_file_content = answer_file.read
27 answer_file_content = answer_file.read
28
28
29 report_correct = lambda {
29 report_correct = lambda {
30 result_file.write "Correct\n"
30 result_file.write "Correct\n"
31 result_file.write problem.get_score(test_num)
31 result_file.write problem.get_score(test_num)
32 result_file.write "\n"
32 result_file.write "\n"
33 result_file.close
33 result_file.close
34 exit(0)
34 exit(0)
35 }
35 }
36
36
37 report_wrong = lambda {
37 report_wrong = lambda {
38 result_file.write "Incorrect\n"
38 result_file.write "Incorrect\n"
39 result_file.write "0\n"
39 result_file.write "0\n"
40 result_file.close
40 result_file.close
41 exit(0)
41 exit(0)
42 }
42 }
43
43
44 ##################
44 ##################
45 # Your code here #
45 # Your code here #
46 ##################
46 ##################
47 num_pattern = /^[0-9]*/
47 num_pattern = /^[0-9]*/
48 if (output_file_content =~ num_pattern) == nil
48 if (output_file_content =~ num_pattern) == nil
49 report_wrong.call
49 report_wrong.call
@@ -1,49 +1,49
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 problem_home = ENV['PROBLEM_HOME']
3 problem_home = ENV['PROBLEM_HOME']
4 require "#{problem_home}/script/test_dsl.rb"
4 require "#{problem_home}/script/test_dsl.rb"
5
5
6 if ARGV.length < 2
6 if ARGV.length < 2
7 puts "Usage: check <language> <test-number> [<output-file>]"
7 puts "Usage: check <language> <test-number> [<output-file>]"
8 exit(0)
8 exit(0)
9 end
9 end
10
10
11 language = ARGV[0]
11 language = ARGV[0]
12 test_num = ARGV[1].to_i
12 test_num = ARGV[1].to_i
13 if ARGV.length >= 3
13 if ARGV.length >= 3
14 output_file_name = ARGV[2]
14 output_file_name = ARGV[2]
15 else
15 else
16 output_file_name = "output.txt"
16 output_file_name = "output.txt"
17 end
17 end
18
18
19 load "#{problem_home}/test_cases/all_tests.cfg"
19 load "#{problem_home}/test_cases/all_tests.cfg"
20 problem = Problem.get_instance
20 problem = Problem.get_instance
21
21
22 output_file = File.new(output_file_name, "r")
22 output_file = File.new(output_file_name, "r")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
24 result_file = File.new("check_result", "w")
24 result_file = File.new("check_result", "w")
25
25
26 output_file_content = output_file.read
26 output_file_content = output_file.read
27 answer_file_content = answer_file.read
27 answer_file_content = answer_file.read
28
28
29 report_correct = lambda {
29 report_correct = lambda {
30 result_file.write "Correct\n"
30 result_file.write "Correct\n"
31 result_file.write problem.get_score(test_num)
31 result_file.write problem.get_score(test_num)
32 result_file.write "\n"
32 result_file.write "\n"
33 result_file.close
33 result_file.close
34 exit(0)
34 exit(0)
35 }
35 }
36
36
37 report_wrong = lambda {
37 report_wrong = lambda {
38 result_file.write "Incorrect\n"
38 result_file.write "Incorrect\n"
39 result_file.write "0\n"
39 result_file.write "0\n"
40 result_file.close
40 result_file.close
41 exit(0)
41 exit(0)
42 }
42 }
43
43
44 ##################
44 ##################
45 # Your code here #
45 # Your code here #
46 ##################
46 ##################
47 num_pattern = /^[0-9]*/
47 num_pattern = /^[0-9]*/
48 if (output_file_content =~ num_pattern) == nil
48 if (output_file_content =~ num_pattern) == nil
49 report_wrong.call
49 report_wrong.call
@@ -1,49 +1,49
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 problem_home = ENV['PROBLEM_HOME']
3 problem_home = ENV['PROBLEM_HOME']
4 require "#{problem_home}/script/test_dsl.rb"
4 require "#{problem_home}/script/test_dsl.rb"
5
5
6 if ARGV.length < 2
6 if ARGV.length < 2
7 puts "Usage: check <language> <test-number> [<output-file>]"
7 puts "Usage: check <language> <test-number> [<output-file>]"
8 exit(0)
8 exit(0)
9 end
9 end
10
10
11 language = ARGV[0]
11 language = ARGV[0]
12 test_num = ARGV[1].to_i
12 test_num = ARGV[1].to_i
13 if ARGV.length >= 3
13 if ARGV.length >= 3
14 output_file_name = ARGV[2]
14 output_file_name = ARGV[2]
15 else
15 else
16 output_file_name = "output.txt"
16 output_file_name = "output.txt"
17 end
17 end
18
18
19 load "#{problem_home}/test_cases/all_tests.cfg"
19 load "#{problem_home}/test_cases/all_tests.cfg"
20 problem = Problem.get_instance
20 problem = Problem.get_instance
21
21
22 output_file = File.new(output_file_name, "r")
22 output_file = File.new(output_file_name, "r")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
24 result_file = File.new("check_result", "w")
24 result_file = File.new("check_result", "w")
25
25
26 output_file_content = output_file.read
26 output_file_content = output_file.read
27 answer_file_content = answer_file.read
27 answer_file_content = answer_file.read
28
28
29 report_correct = lambda {
29 report_correct = lambda {
30 result_file.write "Correct\n"
30 result_file.write "Correct\n"
31 result_file.write problem.get_score(test_num)
31 result_file.write problem.get_score(test_num)
32 result_file.write "\n"
32 result_file.write "\n"
33 result_file.close
33 result_file.close
34 exit(0)
34 exit(0)
35 }
35 }
36
36
37 report_wrong = lambda {
37 report_wrong = lambda {
38 result_file.write "Incorrect\n"
38 result_file.write "Incorrect\n"
39 result_file.write "0\n"
39 result_file.write "0\n"
40 result_file.close
40 result_file.close
41 exit(0)
41 exit(0)
42 }
42 }
43
43
44 ##################
44 ##################
45 # Your code here #
45 # Your code here #
46 ##################
46 ##################
47 num_pattern = /^[0-9]*/
47 num_pattern = /^[0-9]*/
48 if (output_file_content =~ num_pattern) == nil
48 if (output_file_content =~ num_pattern) == nil
49 report_wrong.call
49 report_wrong.call
@@ -1,49 +1,49
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 problem_home = ENV['PROBLEM_HOME']
3 problem_home = ENV['PROBLEM_HOME']
4 require "#{problem_home}/script/test_dsl.rb"
4 require "#{problem_home}/script/test_dsl.rb"
5
5
6 if ARGV.length < 2
6 if ARGV.length < 2
7 puts "Usage: check <language> <test-number> [<output-file>]"
7 puts "Usage: check <language> <test-number> [<output-file>]"
8 exit(0)
8 exit(0)
9 end
9 end
10
10
11 language = ARGV[0]
11 language = ARGV[0]
12 test_num = ARGV[1].to_i
12 test_num = ARGV[1].to_i
13 if ARGV.length >= 3
13 if ARGV.length >= 3
14 output_file_name = ARGV[2]
14 output_file_name = ARGV[2]
15 else
15 else
16 output_file_name = "output.txt"
16 output_file_name = "output.txt"
17 end
17 end
18
18
19 load "#{problem_home}/test_cases/all_tests.cfg"
19 load "#{problem_home}/test_cases/all_tests.cfg"
20 problem = Problem.get_instance
20 problem = Problem.get_instance
21
21
22 output_file = File.new(output_file_name, "r")
22 output_file = File.new(output_file_name, "r")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
24 result_file = File.new("check_result", "w")
24 result_file = File.new("check_result", "w")
25
25
26 output_file_content = output_file.read
26 output_file_content = output_file.read
27 answer_file_content = answer_file.read
27 answer_file_content = answer_file.read
28
28
29 report_correct = lambda {
29 report_correct = lambda {
30 result_file.write "Correct\n"
30 result_file.write "Correct\n"
31 result_file.write problem.get_score(test_num)
31 result_file.write problem.get_score(test_num)
32 result_file.write "\n"
32 result_file.write "\n"
33 result_file.close
33 result_file.close
34 exit(0)
34 exit(0)
35 }
35 }
36
36
37 report_wrong = lambda {
37 report_wrong = lambda {
38 result_file.write "Incorrect\n"
38 result_file.write "Incorrect\n"
39 result_file.write "0\n"
39 result_file.write "0\n"
40 result_file.close
40 result_file.close
41 exit(0)
41 exit(0)
42 }
42 }
43
43
44 ##################
44 ##################
45 # Your code here #
45 # Your code here #
46 ##################
46 ##################
47
47
48 ########### THIS IS FOR CHECKING TEXT ##########
48 ########### THIS IS FOR CHECKING TEXT ##########
49
49
@@ -1,47 +1,47
1 - #!/usr/bin/ruby
1 + #!/usr/bin/env ruby
2
2
3 problem_home = ENV['PROBLEM_HOME']
3 problem_home = ENV['PROBLEM_HOME']
4 require "#{problem_home}/script/test_dsl.rb"
4 require "#{problem_home}/script/test_dsl.rb"
5
5
6 if ARGV.length < 2
6 if ARGV.length < 2
7 puts "Usage: check <language> <test-number> [<output-file>]"
7 puts "Usage: check <language> <test-number> [<output-file>]"
8 exit(0)
8 exit(0)
9 end
9 end
10
10
11 language = ARGV[0]
11 language = ARGV[0]
12 test_num = ARGV[1].to_i
12 test_num = ARGV[1].to_i
13 if ARGV.length >= 3
13 if ARGV.length >= 3
14 output_file_name = ARGV[2]
14 output_file_name = ARGV[2]
15 else
15 else
16 output_file_name = "output.txt"
16 output_file_name = "output.txt"
17 end
17 end
18
18
19 load "#{problem_home}/test_cases/all_tests.cfg"
19 load "#{problem_home}/test_cases/all_tests.cfg"
20 problem = Problem.get_instance
20 problem = Problem.get_instance
21
21
22 output_file = File.new(output_file_name, "r")
22 output_file = File.new(output_file_name, "r")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
23 answer_file = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
24 result_file = File.new("check_result", "w")
24 result_file = File.new("check_result", "w")
25
25
26 output_file_content = output_file.read
26 output_file_content = output_file.read
27 answer_file_content = answer_file.read
27 answer_file_content = answer_file.read
28
28
29 report_correct = lambda {
29 report_correct = lambda {
30 result_file.write "Correct\n"
30 result_file.write "Correct\n"
31 result_file.write problem.get_score(test_num)
31 result_file.write problem.get_score(test_num)
32 result_file.write "\n"
32 result_file.write "\n"
33 result_file.close
33 result_file.close
34 exit(0)
34 exit(0)
35 }
35 }
36
36
37 report_wrong = lambda {
37 report_wrong = lambda {
38 result_file.write "Incorrect\n"
38 result_file.write "Incorrect\n"
39 result_file.write "0\n"
39 result_file.write "0\n"
40 result_file.close
40 result_file.close
41 exit(0)
41 exit(0)
42 }
42 }
43
43
44 ##################
44 ##################
45 # Your code here #
45 # Your code here #
46 ##################
46 ##################
47 report_correct.call
47 report_correct.call
You need to be logged in to leave comments. Login now