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 'pp' | |
class Image | |
attr_accessor :image | |
def initialize(image) | |
@image = image | |
end | |
def output_image | |
@image.each do |e| |
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 Deck | |
attr_accessor :cards | |
def initialize | |
build_every_possible_card | |
end | |
def build | |
self.cards = | |
suits.map do |suit| |
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 Image | |
def initialize(array) | |
@array = array | |
end | |
def output_image | |
@array.each { |a| puts a.join } | |
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
class Deck | |
attr_accessor :size | |
def size | |
cards.size | |
end | |
def cards | |
cards = [] | |
52.times { cards << 1 } |
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 Card | |
attr_accessor :rank, :suit | |
def initialize(rank, suit) | |
self.rank = rank | |
self.suit = suit | |
end | |
def output_card | |
puts "#{self.rank} of #{self.suit}" |
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
# In the above example it will check to see if the payload is 11 in the following order: 2, 7, 6, 5 when | |
# it gets to 5 and 5 has no children, it will return to the 6 and go to any children 6 has. 6 has a | |
# remaining child, which is 11 so that node is checked and since that value is the correct value it | |
# will be returned and searching will stop. | |
class Tree | |
attr_accessor :payload, :children | |
def initialize(payload, children) | |
@payload = payload |
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 LinkedListNode | |
attr_accessor :value, :next_node | |
def initialize(value, next_node = nil) | |
@value = value | |
@next_node = next_node | |
end | |
end | |
def print_values(list_node) |
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 Image | |
attr_accessor :array | |
def initialize(array) | |
@array = array | |
@new_array = @array.map {|e| Array.new(e.size) } | |
end | |
def blur | |
@array.each_with_index do |row,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
Write a method that accepts two arguments: an Array of five guesses for | |
finalists in a race and an Array of the five actual finalists. Each | |
position in the lists matches a finishing position in the race, so first | |
place corresponds to index 0. Return an Integer score of the predictions: | |
0 or more points. Correctly guessing first place is worth 15 points, | |
second is worth 10, and so on down with 5, 3, and 1 point for fifth | |
place. It's also worth 1 point to correctly guess a racer that finishes | |
in the top five but to have that racer in the wrong position. | |
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
# This is the deployment recipe | |
# You require to install runit on the server. | |
# Then you can setup a new runit service with | |
# | |
# make setup_service | |
# | |
# Also you need to install the git hooks, so you can push and update this repo | |
# | |
# make setup_git_hook | |
# |