Great content. I'm doing AoC to lern rust. And yours videos are helping a lot. Another way to anderstand te solution is that we are not calculating the area, we are counting the points in the polygon. So from shoelace teorem A = i +b/2 -1, then the internal points are i = A - b/2 +1, so we add the points in the edge, b, then total_points = i - b/2 +1 + b = i+b/2+1
It was super interesting seeing your thought process for part 2! This one was tough for me. I spent quite a while thinking about it, and even found Pick's theorem, but didn't pursue it because it needed the number of interior points. The solution I landed on involved tracking all the vertical lines, then scanning horizontally, while adding and removing ranges of values to track as I encountered other vertical lines. Then as I scanned, I could multiply the current ranges of rows that I was tracking by the number of columns until the next vertical line. It worked, but it had a lot of edge cases, wasn't pretty, and was slow (about 3 seconds for the full input). I had never heard of the shoelace method, but after seeing your solution I think I'm going to need to refactor mine.
Great content. I'm doing AoC to lern rust. And yours videos are helping a lot.
Another way to anderstand te solution is that we are not calculating the area, we are counting the points in the polygon. So from shoelace teorem A = i +b/2 -1, then the internal points are i = A - b/2 +1, so we add the points in the edge, b, then total_points = i - b/2 +1 + b = i+b/2+1
Ahh, makes a lot of sense!
It was super interesting seeing your thought process for part 2! This one was tough for me. I spent quite a while thinking about it, and even found Pick's theorem, but didn't pursue it because it needed the number of interior points. The solution I landed on involved tracking all the vertical lines, then scanning horizontally, while adding and removing ranges of values to track as I encountered other vertical lines. Then as I scanned, I could multiply the current ranges of rows that I was tracking by the number of columns until the next vertical line. It worked, but it had a lot of edge cases, wasn't pretty, and was slow (about 3 seconds for the full input). I had never heard of the shoelace method, but after seeing your solution I think I'm going to need to refactor mine.
That's a cool idea! I'll have to think about what that would look like in code.
Anything 1:25 man. Content is content. Go share what you have
Awesome! Thanks for the input!
which distro you use and do use vim or emacs ?
I use Arch (btw 😂) and emacs in tmux.