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
# Holiday suppliers | |
# You have a bunch of decorations for various holidays organized by season. | |
holiday_supplies = { | |
:winter => { | |
:christmas => ["Lights", "Wreath"], | |
:new_years => ["Party Hats"] | |
}, | |
:summer => { | |
:forth_of_july => ["Fireworks", "BBQ"] |
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) | |
arr = [] | |
sentence.split.map do |word| | |
reversed = "" | |
i = 0 | |
while i < word.length | |
reversed << word[word.length-(i+1)] | |
i += 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
def create_groups(source, students, groups) | |
arr, src = [], source.shuffle | |
(students*groups/41+1).times {arr += src} | |
arr.slice!(((students*groups)-arr.size)..-1) | |
arr.each_slice(students).to_a | |
end | |
def get_students |
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
pigeons = [] | |
pigeon_list = {} | |
pigeon_data.each {|props, vals| pigeon_data[props]. | |
each {|prop, bird_set| pigeons += bird_set}} | |
pigeons.uniq! | |
pigeons.each do |pigeon| | |
pigeon_list[pigeon] = {:color => [], :gender => "", :lives => ""} |
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
pigeons = [] | |
pigeon_list = {} | |
pigeon_data.each {|properties, properties_hash| pigeon_data[properties]. | |
each {|property, birds| pigeons += birds}} | |
pigeons.uniq! | |
pigeons.each do |pigeon| | |
pigeon_list[pigeon] = {:color => [], :gender => "", :lives => ""} | |
pigeon_data.each do |properties,properties_hash| |
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 School | |
attr_accessor :roster | |
def initialize(school) | |
@roster = {} | |
end | |
def add_student(name, grade) | |
@roster[grade] ||= [] | |
@roster[grade] << name |
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
ArgumentError: wrong number of arguments (2 for 1) |
OlderNewer