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
| class Anagram | |
| attr_reader :word | |
| def initialize(word) | |
| @word = word | |
| end | |
| def match(strings) | |
| strings.select do |string| |
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 "open-uri" | |
| require "Nokogiri" | |
| require "sqlite3" | |
| def create_db | |
| schema = students.first.keys.join(", ") | |
| rows = db.execute <<-SQL | |
| create table students ( | |
| schema | |
| ); |
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
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <ul> | |
| <li> | |
| <a href=http://imgur.com/a/eMkM4> | |
| <h1>My friend having a great time in DC</h1> | |
| <img src=http://c.thumbs.redditmedia.com/mZ49t1GIpxyLU5MD.jpg /> | |
| <h4>Upvotes</h4> |
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 pigs. | |
| pigeon_data = { | |
| :color => { | |
| :purple => ["Theo", "Peter Jr.", "Lucky"], | |
| :grey => ["Theo", "Peter Jr.", "Ms .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 pigs. | |
| pigeon_data = { | |
| :color => { | |
| :purple => ["Theo", "Peter Jr.", "Lucky"], | |
| :grey => ["Theo", "Peter Jr.", "Ms .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
| require 'json' | |
| require 'rest_client' | |
| reddit_hash = JSON.parse(RestClient.get('http://reddit.com/.json')) | |
| def indent(string, num=1) | |
| string.each_line. | |
| map{|line| "#{" " * num}#{line}"}.join | |
| end | |
| def open_tag(string) |
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, num_of_groups) | |
| out_of_order = students.shuffle | |
| groups = [] | |
| index = 0 | |
| num_of_groups.times do | |
| group = [] | |
| group_size.times do |
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,3,4] | |
| 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
| class Array | |
| def version_sort | |
| self.sort_by do |file| | |
| file.scan(/\d+|[a-z]*/).map { |el| el.to_i } | |
| end | |
| end | |
| end | |
| filenames = [ | |
| "foo-1.10.2.ext", |
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 = { | |
| :home => { | |
| :name => "Wu-Tang Clan", | |
| :colors => ["Black", "Yellow"], | |
| :players => [ | |
| { :name => "Method Man", | |
| :number => 6, | |
| :shoe_size => 10, | |
| :stats => { | |
| :points => 49, |