[SOLUTION] NDiff (#46)

<<quiz_46_ndiff.rb>> This quiz made me delve into the darkened
alleyways of undocumented standard libraries (well, bigdecimal). Luckily
the whole thing worked exactly as guessed - probably why nobody has
bothered documenting it yet.

Is there a library that adds the median/average/etc. methods to array? I
rolled that myself because I didn't see it in the std lib.

Also, the statistics bit in the quiz description had "Average" and
"Mean" - I take it that was meant to be Mean and Median? That's what I
implemented.

quiz_46_ndiff.rb (3.93 KB)

···

#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################

Nice solution.

Just one small comment:

...
SyncEnumerator.new(file1, file2).each do |line1, line2|
     line1, line2 = NumberLine.new(line1), NumberLine.new(line2)
     SyncEnumerator.new(line1, line2).collect { |num1, num2| distances << (num1 - num2).abs }
end
...

I'm pretty sure you meant each() instead of collect() for that second SyncEnumerator. I just wanted to point that out, since I changed it in the quiz summary.

James Edward Gray II

···

On Sep 12, 2005, at 8:24 PM, Daniel Sheppard wrote:

<<quiz_46_ndiff.rb>> This quiz made me delve into the darkened
alleyways of undocumented standard libraries (well, bigdecimal). Luckily
the whole thing worked exactly as guessed - probably why nobody has
bothered documenting it yet.