Skip to content

Instantly share code, notes, and snippets.

@umasenthil
Created November 10, 2015 04:11
Show Gist options
  • Save umasenthil/a12ccccdf02338207772 to your computer and use it in GitHub Desktop.
Save umasenthil/a12ccccdf02338207772 to your computer and use it in GitHub Desktop.
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
@umasenthil
Copy link
Author

Input:
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 1],
[0, 0, 0, 0]

Output:
0000
0100
0001
0000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment