Skip to content

Instantly share code, notes, and snippets.

View isomorpheric's full-sized avatar
🐱

Eric Crescioni isomorpheric

🐱
  • US (remote)
View GitHub Profile
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.
class Node
attr_accessor :value, :next_node
def initialize(value, next_node=nil)
@value = value
@next_node = next_node
end
end
class Aircraft
attr_accessor :aircraft, :make
def initialize(aircraft, make)
@aircraft = aircraft
@make = make
end
def describe
# Image Blur #3
class Blur
attr_accessor :array, :blurred_array, :ones
def initialize(array)
@array = array
end
# Image Blur #3
class Blur
attr_accessor :array, :blurred_array, :ones
def initialize(array)
@array = array
end
\# Image Blur 1
class Image
attr_accessor :array , :result_array
def initialize(array)
@array = array
@result_array = array
end
@isomorpheric
isomorpheric / image_blur_2.rb
Last active February 14, 2016 23:15
Image blur 2. Can't get it to work.
# Image Blur 1
class Image
def initialize(array)
@array = array
end
def output_image
@array.each do |row|
# 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