March 2009
Intermediate to advanced
194 pages
4h
English
Well, I don’t know your brithday, so I don’t know how you’d do it, but here’s how I would do it:
# I don't know what second I was born. |
puts(Time.gm(1976, 8, 3, 13, 31) + 10**9) |
# And yes, I had a party. It was awesome |
# (at least the parts I remember). |
2008-04-11 15:17:40 UTC |
How you could do it:
puts 'What year were you born?' |
b_year = gets.chomp.to_i |
puts 'What month were you born? (1-12)' |
b_month = gets.chomp.to_i |
puts 'What day of the month were you born?' |
b_day = gets.chomp.to_i |
b = Time.local(b_year, b_month, b_day) |
t = Time.new |
age = 1 |
while Time.local(b_year + age, b_month, b_day) <= t |
puts 'SPANK!' |
age = age + 1 |
end |
| <= | What year were you born? |
| => | 2009 |
| <= | What month were ... |