This file contains 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
def fizzbuzz | |
for n in 1..50 | |
if (n % 3== 0) && (n % 5 == 0) | |
puts "FizzBuzz" | |
elsif n % 3 == 0 | |
puts "Fizz" | |
elsif n % 5 == 0 | |
puts "Buzz" | |
else | |
nil |
This file contains 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
def seconds_in_minutes(minutes) | |
minutes * 60 | |
end | |
puts seconds_in_minutes(2) | |
def minutes_in_hours(hours) | |
hours * 60 | |
end | |
puts minutes_in_hours(3) |
This file contains 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
song1 = 223 | |
song2 = 215 | |
song3 = 378 | |
song4 = 324 | |
song5 = 254 | |
total_length = song1+song2+song3+song4+song5 | |
puts total_length | |
length_minutes = total_length / 60.0 |
This file contains 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 "What is your first name?" | |
first_name = gets.chomp | |
puts "What is your middle name?" | |
middle_name = gets.chomp | |
puts "What is your last name?" | |
last_name = gets.chomp | |
puts "Did you know that here are " + (first_name.length + middle_name.length + last_name.length).to_s + " characters" | |
puts "in your name, " + first_name.capitalize + " " + middle_name.capitalize + " " + last_name.capitalize + "?" |
This file contains 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 "WHAT DO YOU WANT?" | |
request = gets.chomp | |
puts "WHAT DO YOU MEAN, " + "'" + request.upcase.to_s + "'" + "?! YOU'RE FIRED!!" |
This file contains 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
require 'awesome_print' | |
songs = [ | |
"The Magnetic Fields - 69 Love Songs - Parades Go By", | |
"The Magnetic Fields - Get Lost - Smoke and Mirrors", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945", | |
"The Magnetic Fields - Get Lost - You, Me, and the Moon", | |
"The Magnetic Fields - 69 Love Songs - The Book of Love", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers" | |
] |
This file contains 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
require 'awesome_print' | |
tweet1 = "Hey guys, can anyone teach me how to be cool? I really want to be the best at everything, you know what I mean? Tweeting is super fun you guys!!!!" | |
tweet2 = "OMG you guys, you won't believe how sweet my kitten is. My kitten is like super cuddly and too cute to be believed right?" | |
tweet3 = "I'm running out of example tweets for you guys, which is weird, because I'm a writer and this is just writing and I tweet all day. For real, you guys. For real." | |
tweet4 = "GUISEEEEE this is so fun! I'm tweeting for you guys and this tweet is SOOOO long it's gonna be way more than you would think twitter can handle, so shorten it up you know what I mean? I just can never tell how long to keep typing!" | |
tweet5 = "to two too four for be you at and" | |
$substitutions_hash = { #global variable to work in method | |
"to" => "2", "two" => "2", "too" => "2", "for" => "4", "four" => "4", "be" => "b", |
This file contains 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
$conference_speakers = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"] | |
def badge_printer(speaker_array) | |
speaker_array.each do |name| | |
puts "Hello, my name is #{name}!" | |
end | |
end | |
def room_assignments(speaker_array) | |
speaker_array.each_index do |index| |
This file contains 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
$songs = [ | |
"The Phoenix - 1901", | |
"Tokyo Police Club - Wait Up", | |
"Sufjan Stevens - Too Much", | |
"The Naked and the Famous - Young Blood", | |
"(Far From) Home - Tiga", | |
"The Cults - Abducted", | |
"The Phoenix - Consolation Prizes" | |
] |
This file contains 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
def reverse_each_word(sentence) | |
sentence_array = sentence.split(" ") | |
sentence_array.collect {|word| word.reverse}.join(" ") | |
end | |
puts reverse_each_word("Hello there, and how are you?") | |
#=> "olleH ,ereht dna woh era ?uoy" |