diff options
Diffstat (limited to 'day08/part2')
-rwxr-xr-x | day08/part2 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/day08/part2 b/day08/part2 new file mode 100755 index 0000000..5d56a8c --- /dev/null +++ b/day08/part2 @@ -0,0 +1,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) |