Description:
Merge pull request #1 from nattee/master
change hashbang to /usr/bin/env ruby
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r194:f7ae7aa57090 - - 4 files changed: 4 inserted, 4 deleted
@@ -1,84 +1,84 | |||||
|
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 | puts "YOU HAVE TO EDIT THE CHECKING CODE HERE: #{__FILE__}" |
|
48 | puts "YOU HAVE TO EDIT THE CHECKING CODE HERE: #{__FILE__}" |
|
49 | exit(127) |
|
49 | exit(127) |
|
50 |
|
50 | ||
|
51 | # below are codes for checking integer and text |
|
51 | # below are codes for checking integer and text |
|
52 |
|
52 | ||
|
53 | ########### THIS IS FOR CHECKING INTEGER ########## |
|
53 | ########### THIS IS FOR CHECKING INTEGER ########## |
|
54 | num_pattern = /^[0-9]*/ |
|
54 | num_pattern = /^[0-9]*/ |
|
55 | if (output_file_content =~ num_pattern) == nil |
|
55 | if (output_file_content =~ num_pattern) == nil |
|
56 | report_wrong.call |
|
56 | report_wrong.call |
|
57 | end |
|
57 | end |
|
58 |
|
58 | ||
|
59 | output_i = output_file_content.to_i |
|
59 | output_i = output_file_content.to_i |
|
60 | answer_i = answer_file_content.to_i |
|
60 | answer_i = answer_file_content.to_i |
|
61 |
|
61 | ||
|
62 | if output_i == answer_i |
|
62 | if output_i == answer_i |
|
63 | report_correct.call |
|
63 | report_correct.call |
|
64 | else |
|
64 | else |
|
65 | report_wrong.call |
|
65 | report_wrong.call |
|
66 | end |
|
66 | end |
|
67 |
|
67 | ||
|
68 | ########### THIS IS FOR CHECKING TEXT ########## |
|
68 | ########### THIS IS FOR CHECKING TEXT ########## |
|
69 |
|
69 | ||
|
70 | # check visible text |
|
70 | # check visible text |
|
71 |
|
71 | ||
|
72 | out_items = output_file_content.split |
|
72 | out_items = output_file_content.split |
|
73 | ans_items = answer_file_content.split |
|
73 | ans_items = answer_file_content.split |
|
74 |
|
74 | ||
|
75 | if out_items.length != ans_items.length |
|
75 | if out_items.length != ans_items.length |
|
76 | report_wrong.call |
|
76 | report_wrong.call |
|
77 | else |
|
77 | else |
|
78 | out_items.length.times do |i| |
|
78 | out_items.length.times do |i| |
|
79 | if out_items[i]!=ans_items[i] |
|
79 | if out_items[i]!=ans_items[i] |
|
80 | report_wrong.call |
|
80 | report_wrong.call |
|
81 | end |
|
81 | end |
|
82 | end |
|
82 | end |
|
83 | report_correct.call |
|
83 | report_correct.call |
|
84 | end |
|
84 | end |
@@ -1,62 +1,62 | |||||
|
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 INTEGER ########## |
|
48 | ########### THIS IS FOR CHECKING INTEGER ########## |
|
49 | num_pattern = /^[0-9]*/ |
|
49 | num_pattern = /^[0-9]*/ |
|
50 | if (output_file_content =~ num_pattern) == nil |
|
50 | if (output_file_content =~ num_pattern) == nil |
|
51 | report_wrong.call |
|
51 | report_wrong.call |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
|
54 | output_i = output_file_content.to_i |
|
54 | output_i = output_file_content.to_i |
|
55 | answer_i = answer_file_content.to_i |
|
55 | answer_i = answer_file_content.to_i |
|
56 |
|
56 | ||
|
57 | if output_i == answer_i |
|
57 | if output_i == answer_i |
|
58 | report_correct.call |
|
58 | report_correct.call |
|
59 | else |
|
59 | else |
|
60 | report_wrong.call |
|
60 | report_wrong.call |
|
61 | end |
|
61 | end |
|
62 |
|
62 |
@@ -1,64 +1,64 | |||||
|
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 | ||
|
50 | # check visible text |
|
50 | # check visible text |
|
51 |
|
51 | ||
|
52 | out_items = output_file_content.split |
|
52 | out_items = output_file_content.split |
|
53 | ans_items = answer_file_content.split |
|
53 | ans_items = answer_file_content.split |
|
54 |
|
54 | ||
|
55 | if out_items.length != ans_items.length |
|
55 | if out_items.length != ans_items.length |
|
56 | report_wrong.call |
|
56 | report_wrong.call |
|
57 | else |
|
57 | else |
|
58 | out_items.length.times do |i| |
|
58 | out_items.length.times do |i| |
|
59 | if out_items[i]!=ans_items[i] |
|
59 | if out_items[i]!=ans_items[i] |
|
60 | report_wrong.call |
|
60 | report_wrong.call |
|
61 | end |
|
61 | end |
|
62 | end |
|
62 | end |
|
63 | report_correct.call |
|
63 | report_correct.call |
|
64 | end |
|
64 | end |
@@ -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