Last active
May 7, 2016 05:13
-
-
Save caged/c42ddd2ab41e80bdaa7a1b67f55ac0d4 to your computer and use it in GitHub Desktop.
Revisions
-
Justin Palmer revised this gist
May 7, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ require 'csv' coach_years=CSV.read('coaches2.csv')[1..-1] stints = coach_years.sort_by(&:reverse).each_with_object([]) do |coach_year, coach_stints| season, coach = coach_year start_year = season.split('-')[0].to_i -
Justin Palmer created this gist
May 7, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/usr/bin/env ruby require 'csv' coach_years=CSV.read('coaches2.csv')[1..-1] i = 0 stints = coach_years.sort_by(&:reverse).each_with_object([]) do |coach_year, coach_stints| season, coach = coach_year start_year = season.split('-')[0].to_i end_year = start_year + 1 last_stint = coach_stints.last if [coach, start_year] == last_stint&.fetch_values(:coach, :end_year) last_stint[:end_year] = end_year else coach_stints << { coach: coach, start_year: start_year, end_year: end_year } end end stints.sort_by!{|s| [s[:start_year], s[:end_year]]} puts stints