You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2018/ruby/day_03.rb

14 lines
280 B

p ARGF.read.lines.each.with_object(Hash.new(0)) {|line, fabric|
line =~ /(\d+),(\d+): (\d+)x(\d+)$/
x = $1.to_i
y = $2.to_i
width = $3.to_i
height = $4.to_i
width.times {|dx|
height.times {|dy|
fabric[[y + dy, x + dx]] += 1
}
}
}.count {|_,v| v > 1 }