Module day08

Source
Expand description

ยงTreetop Tree House

Part 1 is solved with an efficient O(n) algorithm. Part 2 is also solved with an efficient O(n) algorithm, using a bit manipulation trick to make the complexity independent of the number of digits.

Constantsยง

MASK ๐Ÿ”’
ONES ๐Ÿ”’

Functionsยง

parse
Convert a 2D grid of ASCII digits into a 1D vec of heights.
part1
Calculate visible trees using a rolling maximum for each row and column in left, right, up and down directions.
part2
Calculate the distance visible in each direction by using 10 rolling maximum values for each height packed into a single u64.

Type Aliasesยง

Input ๐Ÿ”’