This file contains 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
module Luhn | |
attr_reader :digs | |
def self.is_valid?(number) | |
digs = Math.log10(number).floor.downto(0).map { |i| (number / 10**i) % 10 } | |
# Iterate through every 2nd number, starting from left. Reverse array to accomplish that. | |
digs = digs.reverse | |
f_digs = [] | |
# Multiply every 2nd number by 2. If number is greater or equal to 10, substract 9. |
This file contains 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 Node | |
attr_accessor :value, :next_node | |
def initialize(value, next_node=nil) | |
@value = value | |
@next_node = next_node | |
end | |
end |
This file contains 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 Aircraft | |
attr_accessor :aircraft, :make | |
def initialize(aircraft, make) | |
@aircraft = aircraft | |
@make = make | |
end | |
def describe |
This file contains 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
# Image Blur #3 | |
class Blur | |
attr_accessor :array, :blurred_array, :ones | |
def initialize(array) | |
@array = array | |
end |
This file contains 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
# Image Blur #3 | |
class Blur | |
attr_accessor :array, :blurred_array, :ones | |
def initialize(array) | |
@array = array | |
end |
This file contains 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
\# Image Blur 1 | |
class Image | |
attr_accessor :array , :result_array | |
def initialize(array) | |
@array = array | |
@result_array = array | |
end |
This file contains 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
# Image Blur 1 | |
class Image | |
def initialize(array) | |
@array = array | |
end | |
def output_image | |
@array.each do |row| |
This file contains 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
# Image Blur 2 | |
# I have no idea what to do. I'm pretty sure it has to do with making a row method, or a pixel method. | |
# yet I'm up in the air about what to do with them. Last time we spoke, you had mentioned making | |
# another class. If you could point me in the right direction so I can have something more solid tomorrow | |
# it would be awesome. Otherwise, see you then. | |
# The purpose of this problem is to convert any numbers on the top, bottom, left and right of every "1". | |
class Image |
NewerOlder