Last active
August 29, 2015 14:27
-
-
Save kangkyu/083901e4cb54e918929f 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
# Write a method leap_year?. It should accept a year value from the user, check whether it's a leap year, and then return true or false. Note: a century year, like 1900 and 2000, is a leap year only if it is divisible by 400. | |
def leap_year?(year) | |
year % 400 == 0 || year % 100 != 0 && year % 4 == 0 | |
end | |
[1998, 1996, 2000, 2100].each do |year| | |
minutes = if leap_year?(year) | |
366 * 24 * 60 | |
else | |
365 * 24 * 60 | |
end | |
puts "#{minutes} minutes in year #{year}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment