Adapted from CodeKata.
Last month, James showed us how to parse CSV. Here's a chance to practice, and to try something more like a real-world programming problem. You'll want to check out the CSV class in Ruby's standard library to help you.
In weather.csv
you’ll find daily weather data for Morristown, NJ for June 2002. Download this file, then write a program to output the day number with the smallest temperature spread. The day number is in a column labeled Dy
, the max temperature is MxT
and the min temperature is MnT
.
The file football.csv
contains the results from the English Premier League for 2001/2. The columns labeled F
and A
contain the total number of goals scored for and against each team in that season (so Arsenal scored 79 goals against opponents, and had 36 goals scored against them). Write a program to print the name of the team with the smallest difference in ‘for’ and ‘against’ goals.
Take the two programs written previously and factor out as much common code as possible, leaving you with two smaller programs and some kind of shared functionality.