Skip to content

Instantly share code, notes, and snippets.

View samtalks's full-sized avatar

Sam Yang samtalks

View GitHub Profile
# Apple picker
# Create a method, apple_picker, that will pick all the apples out of an array. Implement it with collect and then implement it with select. Write a sentence about how select differs from collect.
def apple_picker(fruits)
answer = []
# Download Gist: https://gist.github.com/scottcreynolds/e6534b284373efe0ba6e/download
# Build a Jukebox
# create a file jukebox.rb
# When that program is run, it should introduce itself
# to the user and accept input from the user using the gets command.
# The jukebox should respond to 4 commands, help, play, list and exit.
# The help command should output instructions for the user
# on how to use the jukebox.
# The list command should output a list of songs that the
@samtalks
samtalks / normalized_phone.rb
Created September 27, 2013 14:22
Morning lab 9/27
# Download this file:
# https://gist.github.com/scottcreynolds/ac1b5c8d96de0c91bf7c/download
# Run it from your terminal with:
# ruby ruby_phone_format.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
@samtalks
samtalks / different_ways.rb
Created September 27, 2013 03:41
9/26 HW: Different ways to...
# Let's go back to the exercise where we determined what is and isn't a vowel. With ruby, there's always more than one way to do something and get the same result.
# Assuming vowels a,e,i,o,u:
# Write a method that returns whether a given letter is a vowel, using if and elsif
def is_vow(letter)
if letter == "a"
true
elsif letter == "e"
true
elsif letter == "i"
true
@samtalks
samtalks / speakers.rb
Created September 27, 2013 01:18
HW on 9/26. Speakers and Room assignments
# You're hosting a conference and need to print badges for the speakers. Each badge should say: "Hello, my name is _____."
# Write a method that will create and return this message, given a person's name.
def badge(name)
puts "Hello, my name is #{name}."
end
# Now the list of speakers is finalized, and you can send the list of badges to the printer. Remember that you'll need to give this list to the printer, so it should be accessible outside of the method.
speaker_list = %w(John Mike Liz Harry Betty)
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"
]
@samtalks
samtalks / gist:6707289
Created September 25, 2013 22:50
HW given on 9/25
FizzBuzz part 1
def fizzbuzz(until_num)
i = 1
while i <= until_num do
if i % 3 == 0 && i % 5 == 0
puts "FizzBuzz"
elsif i % 3 == 0
puts "Fizz"
elsif i % 5 == 0
puts "Buzz"