Skip to content

Instantly share code, notes, and snippets.

@loganhasson
loganhasson / super.messed.up.hanoi.rb
Created October 2, 2013 04:01
Really, really messed up tower of hanoi that is full of multiple ideas smashed together. Not there yet...
a = [1,2,3,4]
b = []
c = []
# initial move
# biggest move possible
# little guy to next one
# biggest move
# little guy
# run this file at the command line: rspec blog_post_scheduler_spec.rb
# remember that tests can be your to-do list, and that you should get one
# test to pass at a time, doing the simplest thing you can for each one.
# read your rspec output carefully to find what you need to fix. the errors
# will guide you!
require_relative './spec_helper.rb'
require_relative './blog_post_scheduler.rb'
# create a method called create_groups that, given an array of student names,
# a group size, and a number of groups, will return an array of groups of
# of students with no student in adjacent groups
def create_groups(student_list, group_size, num_groups)
groups_array = []
random_list = student_list.shuffle
while random_list.size > 0
mini_group = random_list.slice(0,group_size)
@loganhasson
loganhasson / partial.version.sort.rb
Created October 2, 2013 02:45
Only partially working...
require 'awesome_print'
# Version-sorted strings are compared such that if ver1 and ver2 are version
# numbers and prefix and suffix (suffix matching the regular
# expression ‘(\.[A-Za-z~][A-Za-z0-9~]*)*’) are strings then ver1 < ver2
# implies that the name composed of “prefix ver1 suffix” sorts before
# “prefix ver2 suffix”.
class Array
def version_sort(prefix, extension)
##
# 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).
##
# Build a method now_serving. This method should call out (via puts) the next
# person in line and remove them from the line.
##
# 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:
# 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.
# apple_picker(["apple", "orange", "apple"]) #=> ["apple", "apple"]
# with collect
# def apple_picker(fruit_array)
# fruit_array.collect do |fruit|
# fruit if fruit == "apple"
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:forth_of_july => ["Fireworks", "BBQ", "Beer"]
},
:fall => {
:thanksgiving => ["Turkey"]
# movies that organizes by genre
# recipes with ingredients
# user profiles: list of favorite colors, 3 personal essays (essay_1, essay_2, essay_3)
moveies = {
"Action" => ["Skyfall", "Mission:Impossible", "The Dark Knight", "Die Hard"],
"Adventure" => ["Indiana Jones", "Homeward Bound", ""],
"Romantic Comedy" => ["50 First Dates"],
"Drama" => ["Steel Magnolias", "Citizen Kane", "Train Spotting", "Flash"],
"Comedy" => ["In Bruges", "Anchorman", "40 Year Old Virgin"],
def rev_in_place(sentence)
backwards = sentence.split.map { |word| word.reverse }.join(' ')
end