Let's go through the second week of Advent of Code in Rust.
Day 8: Treetop Tree House
tl;dr
We get a forest and we want to know how many trees are visible from the outside. Apart from that we want to find the best view.
Nothing interesting. We are moving around 2D map though. And indexing can get a
bit painful when doing so, let's refactor it a bit ;) During the preparation for
the AoC, I have written Vector2D
and now it's time to extend it with indexing
of Vec
of Vec
s. In my solution I was manipulating with indices in the following
way:
- swapping them
- checking whether they are correct indices for the
Vec<Vec<T>>
- indexing
Vec<Vec<T>>
with them
caution
I'm getting familiar with Rust and starting to “abuse” it… While doing so, I'm also uncovering some “features” that I don't really like. Therefore I will mark all of my rants with thicc