Created
April 29, 2012 13:10
-
-
Save k-hamada/2550377 to your computer and use it in GitHub Desktop.
今後100年間で、今年と同じカレンダーの年を探す
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 'date' | |
first = Date.new(2012, 1, 1) | |
last = Date.new(2012, 12, 31) | |
this_year = [first.wday, last.wday, last.yday] | |
Enumerator.new{|y| | |
loop { | |
first, last = first.next_year, last.next_year | |
y << [first, last] | |
} | |
} | |
.take(100) | |
.find_all{|f, l| | |
[f.wday, l.wday, l.yday] === this_year | |
}.each{|f, l| | |
puts f.year | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment