aoc_omni/ruby/2016/13/problem.rb
2025-11-30 21:22:21 -05:00

15 lines
293 B
Ruby

def wall?(x, y, input)
num = input + ((x*x) + (3*x) + (2*x*y) + y + (y*y))
num.to_s(2).split("").map(&:to_i).reject(&:zero?).count.odd?
end
input = STDIN.read.chomp.to_i
x = (0..80).map do |y|
(0..80).map do |x|
wall?(x, y, input) ? "#" : "."
end.join("")
end.join("\n")
puts x