This file contains hidden or 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
| # Create Some Hashes | |
| ## Create Hashes for the following use-cases. | |
| # - A movie collection that organizes by genres | |
| # - Recipes with ingredients | |
| # - User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3 |
This file contains hidden or 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
| first_line = ["Trevor","Breanna","Annelise","Daniel","Curtis","Robert"] | |
| def take_a_number(line,new_customer) | |
| line << new_customer | |
| first_line = line.length | |
| end | |
| def now_serving(line) | |
| puts "Currently serving " + line.pop | |
| end |
This file contains hidden or 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
| game = { | |
| :the_lakers => { | |
| :name => "The Lakers", | |
| :colors => ["purple","gold"], | |
| :players => { | |
| :daniel_mckendrick => { | |
| :stats => { | |
| :points => 25, | |
| :rebounds => 5, | |
| :assists => 3, |
This file contains hidden or 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 prime?(possible_prime) | |
| test_range = possible_prime / 2 | |
| true | |
| puts !(2..test_range).any? { |number| possible_prime % number == 0 } | |
| end | |
| puts prime?(52) | |
| puts 51/ |
This file contains hidden or 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
| # tower_of_hanoi.rb | |
| a = [1,2] | |
| b = [] | |
| c = [] | |
| # Move the disks from one peg to another following the rules of Hanoi. | |
| # | |
| # number_of_disks - the total number of disks | |
| # from - the starting peg |
This file contains hidden or 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
| # 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(students,group_size,group_count) | |
| new_student_array = [] | |
| i = 0 | |
| j = 0 |
This file contains hidden or 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_url = "http://www.reddit.com/" | |
| reddit_hash = JSON.parse(RestClient.get('http://www.reddit.com/.json')) | |
| #puts reddit_hash["data"]["children"][1] | |
| #reddit_hash["data"].each {|k,v| puts k} |
This file contains hidden or 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
| ######################## | |
| # NYC PIGEON ORGANIZER # | |
| ######################## | |
| # Start with the following collected data on NYC pigeons. | |
| pigeon_data = { | |
| :color => { | |
| :purple => ["Theo", "Peter Jr.", "Lucky"], |
This file contains hidden or 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
| HOMEWORK | |
| 1. SELECT title, sum(amount) | |
| FROM projects | |
| JOIN pledges | |
| ON projects.id = pledges.project_id | |
| GROUP BY title; | |
| 2. SELECT name,age,amount | |
| FROM users JOIN pledges | |
| ON pledges.user_id = users.id; |
This file contains hidden or 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_relative './song_library.rb' | |
| def jukebox(command) | |
| if command.downcase == "list" | |
| list_library | |
| else | |
| parse_command(command) | |
| end | |
| end |