Skip to content

Instantly share code, notes, and snippets.

@jasonnoble
Created July 26, 2009 04:36
Show Gist options
  • Save jasonnoble/155436 to your computer and use it in GitHub Desktop.
Save jasonnoble/155436 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'Date'
print "How much to save? "
save = gets.chomp.gsub('$', '').to_f
puts ''
print "When do you need it? (2009 12 25) "
(year, month, day) = gets.chomp.split(/\s+/).map{|m| m.to_i}
d = Date.new(year, month, day)
weeks = ((d - Date.today) / 7).to_i
amount = sprintf("%.02f", save / weeks)
puts ''
print "To save $#{'%.02f' % save} by #{month}/#{day}/#{year} (#{weeks} weeks),"
print " you need to save $#{amount} / week.\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment