diff options
Diffstat (limited to 'day03')
-rwxr-xr-x | day03/part1 | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/day03/part1 b/day03/part1 index ae16800..79b9d85 100755 --- a/day03/part1 +++ b/day03/part1 @@ -1,9 +1,7 @@ #!/usr/bin/env ruby cloth = Array.new(1000) do - Array.new(1000) do - Array.new - end + Array.new(1000, 0) end input = $stdin.readlines.map(&:chomp).map do |x| @@ -13,7 +11,7 @@ end input.each do |claim| (claim[1]...(claim[1]+claim[3])).each do |c| (claim[2]...(claim[2]+claim[4])).each do |r| - cloth[c][r] << claim[0] + cloth[c][r] += 1 end end end @@ -22,7 +20,7 @@ clashes = 0 cloth.each do |c| c.each do |r| - clashes += 1 if r.length > 1 + clashes += 1 if r > 1 end end |