Show More
Commit Description:
added solution submission with grading
Commit Description:
added solution submission with grading
References:
File last commit:
Show/Diff file:
Action:
app/models/test_pair.rb
| 22 lines
| 667 B
| text/x-ruby
| RubyLexer
|
|
r213 | # TestPair stores an input-solution pair for a problem. This is used | ||
# in a certain "test-pair"-type problem for the CodeJom competition | ||||
# which follows the Google Code Jam format, i.e., a participant only | ||||
# submits a solution to a single random input that the participant | ||||
# requested. This input-solution pair is a TestPair. | ||||
|
r209 | class TestPair < ActiveRecord::Base | ||
|
r213 | belongs_to :problem | ||
|
r214 | |||
def grade(submitted_solution) | ||||
sols = solution.split | ||||
subs = submitted_solution.split | ||||
if sols.length == subs.length | ||||
subs.length.times do |i| | ||||
return false if subs[i]!=sols[i] | ||||
end | ||||
return true | ||||
else | ||||
return false | ||||
end | ||||
end | ||||
|
r209 | end | ||