aoc-2021-rust

Advent of Code 2021 Solutions in Rust
git clone https://git.sinitax.com/sinitax/aoc-2021-rust
Log | Files | Refs | README | sfeed.txt

part1 (1656B)


      1--- Day 15: Chiton ---
      2
      3You've almost reached the exit of the cave, but the walls are getting closer together. Your
      4submarine can barely still fit, though; the main problem is that the walls of the cave are covered
      5in chitons, and it would be best not to bump any of them.
      6
      7The cavern is large, but has a very low ceiling, restricting your motion to two dimensions. The
      8shape of the cavern resembles a square; a quick scan of chiton density produces a map of
      9risk level throughout the cave (your puzzle input). For example:
     10
     111163751742
     121381373672
     132136511328
     143694931569
     157463417111
     161319128137
     171359912421
     183125421639
     191293138521
     202311944581
     21
     22You start in the top left position, your destination is the bottom right position, and you cannot
     23move diagonally. The number at each position is its risk level; to determine the total risk of an
     24entire path, add up the risk levels of each position you enter (that is, don't count the risk level
     25of your starting position unless you enter it; leaving it adds no risk to your total).
     26
     27Your goal is to find a path with the lowest total risk. In this example, a path with the lowest
     28total risk is highlighted here:
     29
     301163751742
     311381373672
     322136511328
     333694931569
     347463417111
     351319128137
     361359912421
     373125421639
     381293138521
     392311944581
     40
     41The total risk of this path is 40 (the starting position is never entered, so its risk is not
     42counted).
     43
     44What is the lowest total risk of any path from the top left to the bottom right?
     45
     46