Last active
July 31, 2016 01:19
-
-
Save emad-elsaid/bff2c346817cb8f7ddfa9366c90035e2 to your computer and use it in GitHub Desktop.
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
We Found 52 Days, Yaaay: | |
2016-08-06 | |
2016-08-13 | |
2016-08-20 | |
2016-08-27 | |
2016-09-03 | |
2016-09-10 | |
2016-09-17 | |
2016-09-24 | |
2016-10-01 | |
2016-10-08 | |
2016-10-15 | |
2016-10-22 | |
2016-10-29 | |
2016-11-05 | |
2016-11-12 | |
2016-11-19 | |
2016-11-26 | |
2016-12-03 | |
2016-12-10 | |
2016-12-17 | |
2016-12-24 | |
2016-12-31 | |
2017-01-07 | |
2017-01-14 | |
2017-01-21 | |
2017-01-28 | |
2017-02-04 | |
2017-02-11 | |
2017-02-18 | |
2017-02-25 | |
2017-03-04 | |
2017-03-11 | |
2017-03-18 | |
2017-03-25 | |
2017-04-01 | |
2017-04-08 | |
2017-04-15 | |
2017-04-22 | |
2017-04-29 | |
2017-05-06 | |
2017-05-13 | |
2017-05-20 | |
2017-05-27 | |
2017-06-03 | |
2017-06-10 | |
2017-06-17 | |
2017-06-24 | |
2017-07-01 | |
2017-07-08 | |
2017-07-15 | |
2017-07-22 | |
2017-07-29 |
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' | |
class Date | |
VALID_FOR_YEARS = 4 # years | |
def valid_for_coup? | |
!(1..VALID_FOR_YEARS).any? do |year| | |
day_in_future_year = next_year(year) | |
day_in_future_year.friday? || day_in_future_year.saturday? | |
end | |
end | |
end | |
valid_days = (Date.today..Date.today.next_year).select(&:valid_for_coup?) | |
if valid_days.empty? | |
puts "Oooooh, can't find any valid days." | |
else | |
puts "We Found #{valid_days.size} Days, Yaaay:" | |
puts valid_days | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment