[2019][ruby][3.b]

sorbet
Alpha Chen 5 years ago
parent 2072187d16
commit 4bb34be4a6

@ -13,11 +13,12 @@ wire_points = wire_paths.map {|path|
when ?D then [x, y-i-1] when ?D then [x, y-i-1]
end end
} }
} }.map.with_index.to_h
} }
intersections = wire_points[0] & wire_points[1] intersections = wire_points[0].select {|k, _| wire_points[1].has_key?(k) }
intersections.delete([0, 0]) intersections.delete([0, 0])
distances = intersections.map {|(x, y)| x.abs + y.abs } # distances = intersections.map {|(x, y), _| x.abs + y.abs }
distances = intersections.map {|p, d| d + wire_points[1].fetch(p) }
puts distances.min puts distances.min

Loading…
Cancel
Save