Method: Clicoder::Judge#float_judge
- Defined in:
- lib/clicoder/judge.rb
#float_judge(file1, file2, absolute_error) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/clicoder/judge.rb', line 19 def float_judge(file1, file2, absolute_error) lines1 = File.read(file1).split($/).map(&:strip) floats1 = lines1.map{ |line| line.split(/\s+/).map(&:to_f) }.flatten lines2 = File.read(file2).split($/).map(&:strip) floats2 = lines2.map{ |line| line.split(/\s+/).map(&:to_f) }.flatten floats1.zip(floats2).each do |float1, float2| return false if (float1 - float2).abs >= absolute_error end true end |