advent_of_code_2024

Module day_2

source
Expand description

This is my solution for Advent of Code - Day 2: Red-Nosed Reports

parse_input uses parse_report to turn the input file into Vec<Report>. first_bad_level_pair is used by both parts to find the first pair that causes the report to be unsafe. analyse_reports solves part 1. report_check_with_dampener applies the more relaxed check for part 2, trying the permutations of dropping a level that might allow the report to pass. analyse_reports_with_dampener uses that to get the part 2 solution.

FunctionsΒ§

  • analyse_reports πŸ”’
    Solves part 1, counting all the reports that are safe as is
  • Solves part 1, counting all the reports that are safe after dampening
  • Find the first pair in the report that either:
  • parse_input πŸ”’
    Parse the input file into a list of reports
  • parse_report πŸ”’
    Parse a line of input as a list of levels
  • If the report is unsafe, it can be considered safe enough if it becomes safe when removing one level.
  • The entry point for running the solutions with the β€˜real’ puzzle input.
  • without_index πŸ”’
    Returns a copy of the input report without the level at the specified index

Type AliasesΒ§