change directory names
This commit is contained in:
parent
3cff0fc5cf
commit
78b8881016
90 changed files with 0 additions and 0 deletions
1347
18/3/input
Normal file
1347
18/3/input
Normal file
File diff suppressed because it is too large
Load diff
31
18/3/main.rb
Normal file
31
18/3/main.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'pry'
|
||||
|
||||
arr = Array.new(1000){Array.new(1000){{count: 0, id: nil}}}
|
||||
|
||||
ids = Array.new
|
||||
dups = Array.new
|
||||
|
||||
File.open("input", "r") do |f|
|
||||
f.each_line do |line|
|
||||
id = line[/\d+/].to_i
|
||||
offset_left, offset_top = line[/\d+,\d+/].split(",").map(&:to_i)
|
||||
width, height = line[/\d+x\d+/].split("x").map(&:to_i)
|
||||
|
||||
ids.push id
|
||||
|
||||
height.times do |y|
|
||||
width.times do |x|
|
||||
arr[offset_top + y][offset_left + x][:count] += 1
|
||||
if arr[offset_top + y][offset_left + x][:id] != nil
|
||||
dups.push arr[offset_top + y][offset_left + x][:id]
|
||||
dups.push id
|
||||
end
|
||||
arr[offset_top + y][offset_left + x][:id] = id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts arr.flatten.select{|a| a[:count] > 1}.count
|
||||
|
||||
puts (ids - dups.uniq)
|
Loading…
Add table
Add a link
Reference in a new issue