Advent of Code 2023 - Day 18 - Rust

Поделиться
HTML-код
  • Опубликовано: 31 дек 2024

Комментарии • 8

  • @Barajamtg
    @Barajamtg 11 месяцев назад +1

    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

    • @icub3d
      @icub3d  11 месяцев назад

      Ahh, makes a lot of sense!

  • @MrTheEdge95
    @MrTheEdge95 Год назад +2

    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.

    • @icub3d
      @icub3d  Год назад

      That's a cool idea! I'll have to think about what that would look like in code.

  • @제인-y9u
    @제인-y9u Год назад +1

    Anything 1:25 man. Content is content. Go share what you have

    • @icub3d
      @icub3d  Год назад

      Awesome! Thanks for the input!

  • @KrishnanshAgarwal
    @KrishnanshAgarwal Год назад +1

    which distro you use and do use vim or emacs ?

    • @icub3d
      @icub3d  Год назад

      I use Arch (btw 😂) and emacs in tmux.