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
#regular fizzbuzz | |
def fizzbuzz(max) | |
(1..max).each do |number| | |
if number % 3 == 0 && number % 5 == 0 | |
puts "FizzBuzz" | |
elsif number % 3 == 0 | |
puts "Fizz" | |
elsif number % 5 == 0 | |
puts "Buzz" | |
else |
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
# 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 | |
# ====================================== |
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
movie = { | |
action: ["Die Hard", "Fight Club"], | |
fantasy: ["Harry Potter", "Lord of the Rings", "Pokemon"] , | |
comedy: ["Scary Movie", "Scary Movie 2", "Grown Ups"] , | |
thriller: ["Freddy Kreuger", "Scream", "Texas Chainsaw Massacrew"], | |
romance: ["The Notebook"] | |
} | |
recipes = { | |
chicken_marsala: ["mushrooms","chicken","white wine", "marsala wine"], |
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 | |
# Instructions | |
# 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(arr) | |
arr.select {|fruit| fruit == "apple"} | |
end | |
def apple_picker(arr) | |
arr.collect {|fruit| fruit if fruit == "apple"}.compact | |
end |
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
nba_finals_game7 = { | |
miami_heat: { | |
colors:["white","red"], | |
players: { | |
lebron_james: {name: "King James", number: "#6", shoe_size: 18, stats: {points: 45, rebounds: 12, assists: 4, steals: 2, blocks: 0, slam_dunks: 10}}, | |
dwyane_wade: {name: "Flash", number: "#3", shoe_size: 15, stats: {points: 23, rebounds: 10, assists: 1, steals: 1, blocks: 0, slam_dunks: 0}}, | |
chris_bosh: {name: "Bosh", number: "#1", shoe_size: 20, stats: {points: 0, rebounds: 7, assists: 2, steals: 1, blocks: 1, slam_dunks: 0}}, | |
shane_battier: {name: "Shane Battier", number: "#31", shoe_size: 18, stats: {points: 18, rebounds: 4, assists: 1, steals: 1, blocks: 2, slam_dunks: 5}}, | |
mario_chalmers: {name: "Jeremy Lin Killer aka Mario Chalmers", number: "#15", shoe_size: 15, stats: {points: 14, rebounds: 0, assists: 2, steals: 2, blocks: 0, slam_dunks: 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
movie = { | |
action: ["Die Hard", "Fight Club"], | |
fantasy: ["Harry Potter", "Lord of the Rings", "Pokemon"] , | |
comedy: ["Scary Movie", "Scary Movie 2", "Grown Ups"] , | |
thriller: ["Freddy Kreuger", "Scream", "Texas Chainsaw Massacrew"], | |
romance: ["The Notebook"] | |
} | |
recipes = { | |
chicken_marsala: ["mushrooms","chicken","white wine", "marsala wine"], |
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 'json' | |
require 'rest_client' | |
reddit_hash = JSON.parse(RestClient.get('http://reddit.com/.json')) | |
filtered_data = reddit_hash["data"]["children"].select do |indiv_post| | |
indiv_post["data"]["over_18"] == false | |
end | |
output = "<html><head></head><body><ul>" |
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
class Anagram | |
attr_accessor :word | |
def initialize(word) | |
@word = word | |
end | |
def match(array) | |
array.select {|item| item.downcase.split("").sort == self.word.downcase.split("").sort} | |
end | |
end |
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
class SecretHandshake | |
attr_accessor :commands | |
def initialize(code) | |
@commands = code_convert_to_commands(code) | |
end | |
def code_convert_to_commands(code) | |
total_commands = [] | |
total_commands << "wink" if code.chars.last == "1" | |
total_commands << "double blink" if code.chars[-2] == "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
class SecretHandshake | |
attr_accessor :commands | |
def initialize(code) | |
@commands = code_convert_to_commands(code) | |
end | |
def code_convert_to_commands(code) | |
total_commands = [] | |
total_commands << "wink" if code.chars.last == "1" | |
total_commands << "double blink" if code.chars[-2] == "1" |
OlderNewer