aboutsummaryrefslogtreecommitdiff
path: root/day08/part2
blob: 5d56a8cfe6d9d99c51da57467e2e7904b3951b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby

W = 25
T = 6

input = $stdin.readlines[0].strip.chars.map(&:to_i)

layers = input.each_slice(W * T).to_a

image = layers.pop

layers.reverse.each do |layer|
  layer.each_index do |i|
    case layer[i]
    when 0
      image[i] = 0
    when 1
      image[i] = 1
    end
  end
end

puts image.map{|p|p == 0 ? " " : "█"}.each_slice(W).map(&:join)