Skip to content

Instantly share code, notes, and snippets.

@volpeo
Created July 4, 2018 12:20
Show Gist options
  • Save volpeo/ce947a94f700b9127e48ee9bd4c4279a to your computer and use it in GitHub Desktop.
Save volpeo/ce947a94f700b9127e48ee9bd4c4279a to your computer and use it in GitHub Desktop.
require "date"
def count_days_to_christmas(date = Date.today)
#today = Date.new(2018, 12, 26)
christmas = Date.new(date.year, 12, 25)
if date > christmas
christmas = Date.new(date.year+1, 12, 25)
end
(christmas - date).to_i
end
puts count_days_to_christmas
puts count_days_to_christmas(Date.new(1990, 12, 19))
puts("Find My Number")
random_number = rand(100)
playing = true
count = 1
max_count = 5
while playing
input = gets.chomp.to_i
if input == random_number
puts "You Won"
playing = false
else
puts "You Lose try Again"
if count >= max_count
playing = false
puts "Try Another Game"
else
if input < random_number
puts "the answer is bigger"
else
puts "the answer is smaller"
end
end
end
count += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment