favor shorter programs
This commit is contained in:
parent
d513374a8a
commit
7bfface1a0
@ -13,9 +13,9 @@ def grade_program(p)
|
|||||||
output = p.execute
|
output = p.execute
|
||||||
grade = (EXPECTED_OUTPUT.size - output.size).abs * 100
|
grade = (EXPECTED_OUTPUT.size - output.size).abs * 100
|
||||||
[EXPECTED_OUTPUT.size, output.size].min.times do |i|
|
[EXPECTED_OUTPUT.size, output.size].min.times do |i|
|
||||||
grade += (ord(EXPECTED_OUTPUT[i]) - ord(output[i])).abs
|
grade += (ord(EXPECTED_OUTPUT[i]) - ord(output[i])).abs * 10
|
||||||
end
|
end
|
||||||
grade
|
grade + p.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def main
|
def main
|
||||||
|
@ -56,6 +56,10 @@ class Program
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def length
|
||||||
|
@instructions.size
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def random_instruction
|
def random_instruction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user