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_accessor :word | |
| def initialize(word) | |
| @word = word | |
| end | |
| def match(array) | |
| @word = @word.split("").sort | |
| array.select { |element| element.split("").sort == @word } |
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
| -- SQL Basic Syntax -- | |
| --initialize SQLite database w/ command line: | |
| sqlite3 database_name.db | |
| --helpful commands | |
| .help -- list of commands | |
| .tables -- see all tables | |
| .mode column / .header on -- helpful for viewing |
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
| teams = { | |
| thebest: { | |
| colors: ["orange","purple"], | |
| players:{ | |
| don: { | |
| number: 1, shoe_size: 9, points: 5, rebounds: 6, assists: 7, steals: 8, blocks: 9, slam_dunks: 10 | |
| }, | |
| jon: { | |
| number: 2, shoe_size: 8, points: 6, rebounds: 7, assists: 8, steals: 9, blocks: 10, slam_dunks: 11 |
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
| teams = { | |
| thebest: { | |
| colors: ["orange","purple"], | |
| players:{ | |
| don: { | |
| number: 1, shoe_size: 9, points: 5, rebounds: 6, assists: 7, steals: 8, blocks: 9, slam_dunks: 10 | |
| }, | |
| jon: { | |
| number: 2, shoe_size: 8, points: 6, rebounds: 7, assists: 8, steals: 9, blocks: 10, slam_dunks: 11 |
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
| katz_deli = [] | |
| def take_a_number(deli_line, customer) | |
| deli_line << customer | |
| deli_line.index(customer) + 1 | |
| end | |
| def now_serving(deli_line) | |
| "Currently serving #{deli_line[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
| holiday_supplies = { | |
| :winter => { | |
| :christmas => ["Lights", "Wreath"], | |
| :new_years => ["Party Hats"] | |
| }, | |
| :summer => { | |
| :forth_of_july => ["Fireworks", "BBQ"] | |
| }, | |
| :fall => { | |
| :thanksgiving => ["Turkey"] |
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
| apple_picker(["apple", "orange", "apple"]) #=> ["apple", "apple"] | |
| apple_picker.map { |x| puts x} | |
| apple_picker.select { |x| puts x } |
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 reverse_each_word(sentence) | |
| sen_array = sentence.split(" ") | |
| sen_rev = sen_array.map { |word| word.reverse} | |
| sen_rev = sen_rev.join(" ") | |
| end | |
| puts reverse_each_word("Hello there, and how are you?") |
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 normalize_phone_number(number) | |
| clean_num = number.gsub(/[^0-9]/, "") | |
| clean_num.length != 10 ? number : "(#{clean_num[0,3]}) #{clean_num[3,3]}-#{clean_num[6,4]}" | |
| 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
| def my_each(array) | |
| i = 0 | |
| while i < array.length | |
| yield(array[i]) | |
| i += 1 | |
| end | |
| end | |
| num_array = [5,6,7,8] |