#!/usr/bin/ruby
require 'date'
puts "Enter your birthdate (YYYY-MM-DD):"
birth = Date.parse(gets, true)
today = Date.today
age = today-birth # in days
min_age = (2 * (age - 7 * 365.25)).round
max_age = (age/2 + 7 * 365.25).round
min_birth = Date.today - min_age
max_birth = Date.today - max_age
puts "Your age pool is #{min_birth.to_s} - #{max_birth.to_s}"
if min_birth > max_birth
puts "You're too young ^__^"
end

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.