Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eternal44/46deeaf94944df0357b1 to your computer and use it in GitHub Desktop.
Save eternal44/46deeaf94944df0357b1 to your computer and use it in GitHub Desktop.
W1C1 - year months, etc.
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