Skip to content

Commit

Permalink
Moved run stuff into check.rb.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Sep 9, 2009
1 parent 0bf320a commit e3a4170
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
35 changes: 21 additions & 14 deletions check.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
ANSWERS = [
['001', 233168],
['002', 4613732],
['003', 6857],
['004', 906609],
['005', 232792560],
['011', 70600674],
['016', 1366],
]
#!/usr/bin/env ruby

ANSWERS = {
'001' => 233168,
'002' => 4613732,
'003' => 6857,
'004' => 906609,
'005' => 232792560,
'011' => 70600674,
'016' => 1366,
}

def check(prog, answer)
start = Time.now
actual = `ruby e#{prog}.rb`.to_i
delta = Time.now - start
if actual == answer
puts "e#{prog}.rb: OK (#{delta} seconds)"
printf "e#{prog}.rb: %20d OK (%0.3f seconds)\n", answer, delta
else
puts "e#{prog}.rb:expected #{answer}, but got #{actual} (#{delta} seconds)"
puts "e#{prog}.rb: expected #{answer}, but got #{actual} (#{delta} seconds)"
end
end

ANSWERS.each do |prog, answer|
check(prog, answer)
if ARGV.empty?
ANSWERS.keys.each do |prog|
answer = ANSWERS[prog]
check(prog, answer)
end
else
prog = "%03d" % ARGV.first.to_i
check(prog, ANSWERS[prog])
end

11 changes: 0 additions & 11 deletions run.rb

This file was deleted.

0 comments on commit e3a4170

Please sign in to comment.