Created
November 10, 2015 04:11
-
-
Save umasenthil/a12ccccdf02338207772 to your computer and use it in GitHub Desktop.
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 | |
puts str[i] | |
end | |
return | |
end | |
end | |
image = Image.new([ | |
[0, 0, 0, 0], | |
[0, 1, 0, 0], | |
[0, 0, 0, 1], | |
[0, 0, 0, 0] | |
]) | |
image.output_image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Input:
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 1],
[0, 0, 0, 0]
Output:
0000
0100
0001
0000