Skip to content

Instantly share code, notes, and snippets.

Sam Yang samtalks

  • New York City
Block or report user

Report or block samtalks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:6913408
ArgumentError: wrong number of arguments (2 for 1)
View school.rb
class School
attr_accessor :roster
def initialize(school)
@roster = {}
end
def add_student(name, grade)
@roster[grade] ||= []
@roster[grade] << name
View pigeon_organizerv2.rb
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|
View pigeon_organizer.rb
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 => ""}
View blog_schedule.rb
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
View hashketball.rb
# sam's algorithm for solving these.
# first, lay out three panels: screen shot of data below, bash window, & subl for visualization
# second, drill down carefully solving for entire set of a kind for results
# third, apply the 'filter' or the conditional to narrow results
game = {
:home => { :team_name => "Charlotte Hornets",
:colors => ["Turquoise", "Purple"],
:players => [
View reverse_words.rb
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
View holidays.rb
# 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"]
View hashes.rb
# Movie collection by genre
movies = {
:animation => ["Incredibles", "Little Mermaid", "Cars"]
:comedy => ["Zoolander", "Groundhog Day"],
:drama => ["Little Women", "JFK", "Black Stallion"]
}
# Recipes with ingredients
View deli_counter.rb
# You need to program the "Take a Number" feature for a deli. At the start, the deli is empty and is represented by an empty array.
# Build a method that a new customer will use when entering our deli. The method, take_a_number, should accept the current line of people, along with the new person's name, and return their position in line (and no 0 index, these are normal people, if they are 7th in line, tell them that, not 6).
def take_a_number(place, person)
place << person
place.length.to_s
end
# Build a method now_serving. This method should call out (via puts) the next person in line and remove them from the line.
You can’t perform that action at this time.