Function aoc::year2018::day06::part1

source ยท
pub fn part1(input: &Input) -> i32
Expand description

Sweep line approach computing the area of each finite coordinate. A coordinate has infinite area if any point on the edge of the bounding box formed by the minimum and maximum x and y coordinates is closest to that coordinate.

We sort the coordinates in ascending x value then for each row, compare the next coordinate against the head of a stack. This quickly eliminates coordinates that are further away at all points. Interestingly this approach is very similar to the previous Day 5.