Day 6: Guard Gallivant | Advent of Code 2024

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

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

  • @koushikm
    @koushikm 18 дней назад +1

    For bounds checking the column, we want 0

    • @WilliamYFeng
      @WilliamYFeng  18 дней назад

      true! i've just noticed that most grids in aoc are square, so it was faster for me to think about just n and not both n and m.

  • @TheFrogfather1
    @TheFrogfather1 18 дней назад +1

    Got there eventually - again there was a day job to do in between parts 1 and 2. Spent a long time with a confusing off by one error caused by me forgetting that Pascal strings are 1 indexed. I have known this for over 40 years! Oh dear.

    • @WilliamYFeng
      @WilliamYFeng  18 дней назад +2

      woah! using pascal sounds super cool. glad you got it!

  • @gorkemeldeniz9579
    @gorkemeldeniz9579 19 дней назад

    I did exactly the same approach execpt the checking only the guard paths
    this is good enhancement for performance thank you William

  • @benjamin7480
    @benjamin7480 19 дней назад +2

    Imagine waiting all that time for the bruteforce to finish and then finding out the answer is wrong lol

    • @WilliamYFeng
      @WilliamYFeng  18 дней назад

      that would be horrible 😓 but getting the right answer on part 1 gave me confidence!

  • @isakblomster43
    @isakblomster43 19 дней назад +1

    Just a heads up the part 2 solution is off by one, only for certain inputs since "The new obstruction can't be placed at the guard's starting position - the guard is there right now and would notice." And this solution does not account for this.

  • @xsni12
    @xsni12 10 дней назад

    i don't understand one thing - why don't you need to store a direction in og_seen set?
    in part 2 when going through the og_seen set, you always go through directions starting from going up, even if the guard originally didn't go up, how does it work correctly? can't wrap my brain around it

    • @WilliamYFeng
      @WilliamYFeng  4 дня назад

      i believe the problem statement says that the guard always originally faces up.

  • @hoangfromvietnam
    @hoangfromvietnam 4 дня назад

    bro it's like you know the question beforehand you don't even trying to read the question and graph it out just go straight to code. May I ask how did you do that?

    • @WilliamYFeng
      @WilliamYFeng  4 дня назад

      i look at the example inputs to try and understand how the problem works. usually reading all the flavortext is not requred.

  • @Ryan-od1ev
    @Ryan-od1ev 18 дней назад

    hey, how do you get that progress bar in your terminal once you run your code? is it a vsc extenson? i also did part 2 using brute force, but with no progress bar, it was hard to know if the program was even running

    • @OlympusTiger
      @OlympusTiger 18 дней назад

      There are some python libraries that can do the progress bar . Here he uses tqdm.

    • @WilliamYFeng
      @WilliamYFeng  18 дней назад

      yep, i use tqdm (github.com/tqdm/tqdm). very convenient, pretty much a drop-in for automatic progress bars.

  • @enjoful
    @enjoful 18 дней назад +1

    Cool!

  • @bohs2000
    @bohs2000 19 дней назад +1

    your "makes_loop if right shape" logic is where I'd like to go, but the logic makes my brain hurt.
    (shape can be rotated, and scaled up in each dimension, and counted if missing obstacle is on current path *and* is in right orientation... yada yada)