Skip to content

Instantly share code, notes, and snippets.

@kissu
Created January 21, 2025 17:20
Show Gist options
  • Save kissu/b1c32bf6447075ac06b573cf205d8f2f to your computer and use it in GitHub Desktop.
Save kissu/b1c32bf6447075ac06b573cf205d8f2f to your computer and use it in GitHub Desktop.
Programming Basics
def coach_answer(your_message)
if your_message.upcase == "I AM GOING TO WORK RIGHT NOW!"
return ""
elsif your_message.end_with?("?")
return "Silly question, get dressed"
else
return "I don't care"
end
end
require_relative "./coach_answer.rb"
puts "Hello, I am your coach, what did you want to tell me?"
condition = true
while condition != ""
print "> "
message = gets.chomp
condition = coach_answer(message)
puts condition
end
puts "Great, see ya!"
# random number 1 to 100
# ask the user a number
# lower than my random secret number
# or higher
# you WIN! 🎖️
# return the amount of tries done by the user
guess_number = rand(100)
puts "Guess a number 🤡"
input = gets.chomp.to_i
counter = 0
puts input
while input != guess_number
if input > guess_number
puts "My guess is lower"
input = gets.chomp.to_i
elsif input < guess_number
puts "My guess is higher"
input = gets.chomp.to_i
end
counter += 1
end
puts "You won in #{counter} times"
require 'date'
# method return numbers of days until next Xmas
def countdown
today = Date.today + 1
xmas = Date.new(2025, 12, 26)
return (xmas - today).to_i
end
puts countdown.class == Integer
puts countdown == 338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment