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
my_none?([1,2,3]) { |x| x == 4 } |
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
# Hashketball Nests | |
# | |
# Great news! You're going to an NBA game! The only catch is that you've been | |
# volunteered to keep stats at the game. | |
# | |
# Using Nested Hashes, define a game, with two teams, their players, and the players stats: | |
# | |
# The game has two teams. | |
# | |
# A team has: |
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
katz_deli = [] | |
def take_a_number(deli, name) | |
deli << name | |
puts deli.index(name)+1 | |
end | |
def now_serving(deli) | |
puts "Currently serving #{deli[0]}" | |
deli.shift |
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
# Apple Picker | |
# Skills: Collect and Select | |
def apple_picker_collect(fruits=["apple", "orange", "apple"]) | |
only_apples = fruits.collect do |x| | |
x if x == "apple" | |
end | |
only_apples.compact! |
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
# A movie collection that organizes by genres | |
# Recipes with ingredients | |
# User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3 | |
## Hashes | |
movie_collection = { | |
:action => ["Man on Fire", "Fight Club"] | |
:adventure => ["National Treasure", "National Treasure 2"] | |
:comedy => ["BASEketball", "Wedding Crashers"] |
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
# Tweet Keyword Shortener | |
# "to, two, too" become '2' | |
# "for, four" become '4' | |
# 'be' becomes 'b' | |
# 'you' becomes 'u' | |
# "at" becomes "@" | |
# "and" becomes "&" | |
# Possible Regexes |
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
# Given this List of Songs, Construct Arrays by Artist and Album | |
# Hint: Make use of the split() String Method | |
# http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split | |
# Simple Example of Data Parsing | |
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", |
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
# 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. | |
# 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. | |
# Modify your method so it can take a list of names as an argument and return a list of badge messages. | |
# Your conference speakers are: Edsger, Ada, Charles, Alan, Grace, Linus and Matz. How you scored these luminaries is beyond me, but way to go! |
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
# Write a program that tells you the following: | |
# | |
# Hours in a year. How many hours are in a year? | |
# Minutes in a decade. How many minutes are in a decade? | |
# Your age in seconds. How many seconds old are you? | |
# | |
# Define at least the following methods to accomplish these tasks: | |
# | |
# seconds_in_minutes(1) | |
# minutes_in_hours(1) |
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
# assignment.rb | |
# FizzBuzz - The Programmer's Stairway to Heaven | |
# Define the fizzbuzz method to do the following: 10pts | |
# Use the modulo % method (divisible by) | |
# 2 % 2 #=> true | |
# 1 % 2 #=> false | |
# If a number is divisible by 3, puts "Fizz". | |
# If a number is divisible by 5, puts "Buzz". | |
# If a number is divisible by 3 and 5, puts "FizzBuzz" |