Created
April 7, 2011 05:04
-
-
Save showell/907068 to your computer and use it in GitHub Desktop.
weather part of "data munging" kata
This file contains hidden or 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
require 'pp' | |
def lines(fn) | |
File.open(fn) do |f| | |
return f.readlines | |
end | |
end | |
def data | |
lines('weather.dat').map do |line| | |
if line =~ /(\d+)\s+(\d+)\s+(\d+)/ | |
[$1, $2, $3].map { |col| col.to_i } | |
end | |
end.compact | |
end | |
strangest_day = data.max_by do |day, max, min| | |
max - min | |
end | |
pp strangest_day |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment