This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First version with a bunch of excess variables | |
# direct from Mr. Pine | |
def ask question | |
good_answer = false | |
while (not good_answer) | |
puts question | |
reply = gets.chomp.downcase | |
if (reply == 'yes' or reply == 'no' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Repo Man | |
def thirsty_bitch | |
puts "get me another" | |
beer | |
end | |
def beer | |
puts "Red Stripe." | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# table of contentssss | |
line_width = 40 | |
puts ('Table of Contents'.center(line_width)) | |
table = [ | |
[1, 'Getting Started', 1], | |
[2, 'Numbers', 9], | |
[3, 'Letters', 13] | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# alphabetting | |
puts 'Tell us some of your favorite things!' | |
# create an array | |
words = [] | |
puts words | |
while (thing = gets.chomp) != '' | |
words.push thing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# deaf gramma | |
# so she says hi and stuff | |
puts 'MORNIN SONNY! HOW YOU DOIN\' TODAY?' | |
hwat = gets.chomp | |
# set a counter that tracks how many times you tell her to DIE | |
counter = 1 | |
# tell her to shut the fuck up | |
while counter != 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# branching again | |
puts 'Hello, world.' | |
puts 'My name is Inigo Montoya. What\'s your name?' | |
name = gets.chomp | |
if name == name.capitalize | |
# be all kinds of sweet | |
puts 'I\'ve always loved the name ' + name + ',' | |
puts '...but I\'m going to call you Pretty-Pretty.' | |
puts 'You\'re very pretty, Pretty-Pretty'.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 99 bottles of beer on the wall | |
# get a number of bottles | |
puts 'How many bottles do you have?' | |
bottles = gets.chomp.to_i | |
# set the loop to go til there are no more bottles | |
# we should be able to do this as an ".each do ||" | |
# but ruby has the hate today. | |
while bottles != 0 | |
# get the song going |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Leap Years | |
# well, we need a year. | |
puts 'Pick a year any year!' | |
year = gets.chomp | |
# then we need to see if it is divisible by 4 | |
# and not 100 | |
# unless it's also divisible by 400 | |
# could use % which is 'modulus' and divides the number but |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Tell us a palindrome" | |
palindrome = gets.chomp | |
if palindrome == palindrome.reverse | |
puts "WOW! " + palindrome.upcase + " IS AN AWESOME PALINDROME!" | |
else | |
puts "Uhhh... " + palindrome.reverse.upcase + " ? Really? That is so not the same as " + palindrome.upcase + "." | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Greed is a dice game where you roll up to five dice to accumulate | |
# points. The following "score" function will be used calculate the | |
# score of a single roll of the dice. | |
# | |
# A greed roll is scored as follows: | |
# | |
# * A set of three ones is 1000 points | |
# | |
# * A set of three numbers (other than ones) is worth 100 times the | |
# number. (e.g. three fives is 500 points). |
NewerOlder