Module aoc::y22d08

source ·
Expand description

Advent of Code 2022 Day 8: https://adventofcode.com/2022/day/8

Overall this solution is a little bit ugly and a lot of brute force; there are probably better ways to solve this. We start by parsing the input (we do an initial pass n*n complexity) to convert the strings in the input into a vector of integer vectors which saves us having to do the parse for every comparison. Then we look at interior trees only. In part one we can do a simple calculation based on the dimensions to account for them without needing to loop through and account for them if x/y==0/len and in part two we can ignore them because as edge trees they have one side with a viewing distance of zero which when multiplied by any other viewing distance will obviously result in a scenic score of zero too. For part two we use the usual std::collections::BinaryHeap to keep track of the tree with the highest scenic score value.

Functions§

  • The solution for the day eight challenge.