Skip to content

Instantly share code, notes, and snippets.

@samueldowens
samueldowens / Alien Sandwich
Created September 24, 2013 00:41
This is my homework submission for the Alien Sandwich assignment...
1. Place the bread in front of you.
2. Place the plate to the side of the bread.
3. Remove the tie from the bag of bread.
4. Remove the first piece of bread from the bag and set it aside.
5. Remove the next two slices of bread and put them next to one another on the plate.
6. Place the set aside piece of bread back into the bag.
7. Re-tie the bread bag so that it is sealed.
8. Move the bread bag out of your way.
9. Place the peanut butter in front of you.
10. Put the knife next to the peanut butter.
@samueldowens
samueldowens / gist:6693057
Created September 24, 2013 23:59
first sql homework
CREATE TABLE artists(
worstbandname TEXT,
fartsperday INTEGER
);
ALTER TABLE artists ADD COLUMN instrument TEXT;
DROP TABLE artists;
CREATE TABLE artists(
@samueldowens
samueldowens / gist:6721035
Created September 26, 2013 21:44
music sorting hw
# 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",
@samueldowens
samueldowens / gist:6721674
Created September 26, 2013 22:48
Day 4 Homework 1
#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!
@samueldowens
samueldowens / gist:6721682
Created September 26, 2013 22:49
day 4 homework part 2
#Let's go back to the exercise where we determined what is and isn't a vowel. With ruby, there's always more than #one way to do something and get the same result.
#
#Assuming vowels a,e,i,o,u:
#
# Write a method that returns whether a given letter is a vowel, using if and elsif
# Write a method that returns whether a given letter is a vowel, using case
# Write a method that returns whether a given letter is a vowel, using if with no else, all on a single line
#Write a method that returns whether a given letter is a vowel without using if or case while all on a single #line
# Write a method that returns whether a given letter is a vowel without checking equality, or the use of if, #using the array of vowels
#Write a method that will evaluate a string and return the first vowel found in the string, if any
@samueldowens
samueldowens / gist:6728817
Created September 27, 2013 13:45
todo FI Day 5
def normalize_phone_number(number)
array = number.split("")
finalnum = []
array.each do |var|
if "1,2,3,4,5,6,7,8,9,0".include?(var)
finalnum << var
end
end
@samueldowens
samueldowens / gist:6733444
Created September 27, 2013 18:51
Sam's Jukebox
#Jukebox Program
#Greeting and setup for the program.
puts "Hello and welcome to the jukebox."
puts "Please let me know your name..."
name = gets.chomp
puts ""
puts "Okay #{name.capitalize}, let me tell you how this works."
puts ""
puts "You can type any of the following commands..."
@samueldowens
samueldowens / gist:6772496
Created October 1, 2013 00:52
Hashketball...
# overall hash
# 2 subhashes, team 1 and team 2
# each team has 3 subhashes name, colors, players
# name = just pointer
# colors = array
# players = array
# player has the following hashes in an array: name, number, shoe_size, points, rebounds, assists, steals, blocks, slam_dunks
hashketball =
@samueldowens
samueldowens / gist:6778993
Created October 1, 2013 14:07
holiday supplier questions
1. holiday_supplies[:summer][:forth_of_july][1]
2. holiday_supplies[:winter][:christmas] << "Tree"
3. holiday_supplies[:spring][:memorial_day] << "Charcoal"
4. holiday_supplies[:summer].merge!(:august_second => ["cake", "booze"])
5.
@samueldowens
samueldowens / gist:6786003
Created October 1, 2013 22:11
Tower of Hanoi: Brute Force Method
#Tower of Hanoi
#rules:
# arrays will be the pegs
# each array goes from top on left to bottom on right
# win/stop when c = [1,2,3,4]
#pieces cannot go to a space where a lower number is farther into the array.
def move_disc
a = [1,2,3,4]