Function advent_of_code_2021::day_7::find_triangular_distance_to_mean[−][src]

fn find_triangular_distance_to_mean(positions: &Vec<usize>) -> usize
Expand description

Very similar to find_distance_to_median with three differences:

  • Calculate mean instead of median for the target position
  • Map the resulting fuel cost using the triangular number distance
  • Calculate the total for the integer values both sides of the mean and take the lowest (see main description)