Created
August 9, 2015 06:57
-
-
Save eternal44/46deeaf94944df0357b1 to your computer and use it in GitHub Desktop.
W1C1 - year months, etc.
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
def convert(x) | |
x.each do |b| | |
a = b / 60.0 / 60.0 / 24.0 / 365.0 * 12.0 | |
a = a.to_i | |
if a % 12 != 0 | |
months = a % 12 | |
months = " and #{months} months" | |
end | |
years = a / 12 | |
puts "I'm #{years} years#{months} old." | |
end | |
end | |
ages = [979000000, 2158493738, 246144023, 1270166272, 1025600095] | |
convert(ages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment