Skip to content

Instantly share code, notes, and snippets.

@arthur-littm
Created October 3, 2017 17:15
Show Gist options
  • Save arthur-littm/14c0158934cc01c966c7c6674ffc6e04 to your computer and use it in GitHub Desktop.
Save arthur-littm/14c0158934cc01c966c7c6674ffc6e04 to your computer and use it in GitHub Desktop.
counter = 1
#generate random number between 1-100
price = rand(1..2)
puts "guess a number chump"
pick = gets.chomp.to_i
p pick
until pick == price
if pick < price
puts "A little higher! Try again"
else
puts "A little lower, try again"
end
counter += 1
pick = gets.chomp.to_i
end
puts "You're a telepath"
if counter > 1
verb = "tries"
else
verb = "try"
end
puts "It took you #{counter} #{verb}"
require 'date'
def days_to_xmas(somedate = Date.today)
# TODO
# 1. get today's date
# 2. get the christmas date
# 3. return the difference
today = somedate
xmas_day = Date.new(Date.today.year, 12, 25)
if today > xmas_day
xmas_day = Date.new(Date.today.year + 1, 12, 25)
end
return (xmas_day - today).to_i
end
puts days_to_xmas
puts days_to_xmas(Date.today + 7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment