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 Linked_list | |
attr_accessor :value, :next_node | |
def initialize(value, next_node =nil) | |
@value = value | |
@next_node = next_node | |
end | |
end | |
class Stack | |
attr_accessor :data |
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(darray) | |
@arr = darray | |
end | |
def get_one_indices | |
# Get one indices | |
@ones_indices = [] | |
@arr.each_index do |i| | |
@arr.each_index do |j| |
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(darray) | |
@arr = darray | |
end | |
def output_image | |
str = [] | |
ones_indices = [] | |
@height = @arr.length | |
@arr.each_index do |i| |
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(darray) | |
@arr = darray | |
end | |
def output_image | |
str = [] | |
length = @arr.length | |
@arr.each_index do |i| | |
str[i] = @arr[i].join('').to_s |
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 Clock | |
attr_accessor :hour, :mins, :secs | |
def initialize(hour, mins, secs) | |
self.hour = hour | |
self.mins = mins | |
self.secs = secs | |
end | |
def show_time |