Created
April 15, 2013 22:37
-
-
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
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
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