Skip to content

Instantly share code, notes, and snippets.

@jamesdabbs
Created April 15, 2013 22:37
Show Gist options
  • Save jamesdabbs/5391861 to your computer and use it in GitHub Desktop.
Save jamesdabbs/5391861 to your computer and use it in GitHub Desktop.
My solution to EPP13 puzzle #7 - jfmamjJASONd. Puzzle available at: http://www.ericharshbarger.org/epp/2013/puz/07_jfmamjJASONd/jfmamjJASONd_v04.pdf
require 'colorize'
require 'csv'
def color? date
date.wday == 5 # Friday
end
CSV.foreach('grid') do |row|
row.each do |cell|
next unless cell
month, year = cell.split ','
year = "0#{year}" if year.to_i < 10
month = "0#{month}" if month.to_i < 10
pref = year.to_i <= 13 ? 20 : 19
formatted = "#{pref}#{year} #{month} 13"
date = Date.strptime formatted, '%Y %m %d'
if color? date
print " ".on_white
else
print " "
end
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment