Function advent_of_code_2021::day_5::get_intersections[−][src]

fn get_intersections(lines: &Vec<Line>) -> HashSet<(usize, usize)>
Expand description

For each line, iterate over it’s points adding each to a set (visited at least once). If that insert fails, we’ve already seen that point so add it to a second set (visited at least twice). Points repeated more than twice can be ignored, as this is not needed to provide the puzzle solution. Return that set, the length of the set will give the number of points where two of more lines intersect.