Created
February 26, 2012 18:41
-
-
Save Canx/1918215 to your computer and use it in GitHub Desktop.
kata 4: data munging (part 1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = Array.new | |
File.foreach("weather.dat") { |line| | |
if line =~ /^\s+([0-9]+)\s+([0-9]+)[*]?\s+([0-9]+)[*]?/ then | |
data << {:day => Integer($1), :spread => Integer($2) - Integer($3)} | |
end | |
} | |
puts data.min { |a,b| a[:spread] <=> b[:spread] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment