Advent of Code 2024 Day 14

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

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

  • @HITNUT
    @HITNUT 5 часов назад +5

    the solution to part 2 is that no 2 robots should be in the same cell. why this works idk

    • @mathiaskern7031
      @mathiaskern7031 2 часа назад +3

      I suspect this has to do with how the puzzle was constructed. Starting point was probably the grid with the Christmas tree and overall N robots in distinct locations, and then the generator randomly choses vx, vy for each robot and a number of seconds to work backwards to generate the puzzle input.

    • @rastislavsvoboda4363
      @rastislavsvoboda4363 2 часа назад

      @@mathiaskern7031
      this is nice approach
      and works quite fast
      def check_area(robots):
      robot_positions = set([(px, py) for px, py, _, _ in robots])
      return len(robot_positions) == len(robots)

  • @rastislavsvoboda4363
    @rastislavsvoboda4363 3 часа назад +1

    0) my first instinct was that picture would be vertically symmetric, but it did not work, so tried cc
    1) I've counted not how many connected components are there, but what is the size of biggest cc
    started with threshold at 10, 20, 30 and found a tree ;-); using all 8 neighbours
    2) Eric did not highlighted that robots at middle axes don't count
    3) modulo ;-)
    px = (px + vx + width) % width
    py = (py + vy + height) % height

  • @JoeyRH
    @JoeyRH 8 часов назад +5

    At 1:26 I'm surprised to see while loops instead of just %, but you were faster than me, so I'm not one to judge!
    Edit: Oh I think you're trying to avoid using mod on negative numbers. But it's nicely behaved in Python to only map to the range [0, m)

  • @dernett
    @dernett 8 часов назад +2

    I initially thought that the image would be symmetrical so we could use the quadrant counts from part 1, but I guess that would have been too easy?

  • @alex_lavoie
    @alex_lavoie 9 часов назад +3

    For pt2, I ended up just print out all the states to a file then searching for a line with a bunch of robots next to each other (assuming that would only happen for the valid answer). Once you know the pattern, it's quite easy to find the answer.

  • @NikiPiano
    @NikiPiano 5 часов назад

    My idea for part 2 was that the tree probably has a stem, so I printed out states with long vertical lines (at least 10), which immediately gave me the tree state. It wasn‘t the stem but the boundary of the image, so I got a bit lucky.

    • @gsainsbury86
      @gsainsbury86 5 часов назад

      I tried something similar but was counting just the number in each row/column, rather than contiguous, so I was getting a lot of noise. I'm frustrated that I gave up and looked for a picture of someone else's tree and then discovered I'd been on the right track.

  • @prateeksaraswat1
    @prateeksaraswat1 3 часа назад

    Nicely done with the second part! quite clever. I was very happy to see my tree printed!!

  • @mathiaskern7031
    @mathiaskern7031 8 часов назад +1

    My heuristic for part 2: the number of grid positions that have a robot and also have robots in all 4 neighbour cells must be at least k; I used k=10.

    • @rastislavsvoboda4363
      @rastislavsvoboda4363 3 часа назад

      just luck, because tree could be only outlined

    • @mathiaskern7031
      @mathiaskern7031 3 часа назад

      @@rastislavsvoboda4363 In the absence of any clear definition of what the Christmas tree would look like, it was a fair - and successful - guess, hence I wrote it was a heuristic. The aim is to solve the puzzle given, not to develop a solution for every possible case. Your solution based on a large connected component is equally a guess - the tree could have been formed by robots which are two cells apart and thus do not appear connected. But it is a very sound guess, and it worked.

    • @rastislavsvoboda4363
      @rastislavsvoboda4363 2 часа назад

      @@mathiaskern7031 no problem, we are programmers and sometimes we need luck;
      otherwise you need to generate pic by pic and try AI if it can see a tree there ;-)

  • @Bl4ckthunder
    @Bl4ckthunder 2 часа назад

    Haha your poor tree fallen to the side. Good Video

  • @dolorsitametblue
    @dolorsitametblue 7 часов назад

    I solved part 2 just by looking at states after each simulation. It's easy to spot a pattern, for my input after 99th, every 101st iterations robots gathered closer to center of grid, so I started printing only "interesting" grids and found the easter egg after 7371 (72 interesting) iterations.

  • @CAG2
    @CAG2 9 часов назад

    what a funny puzzle, looks like it's a puzzle in heuristics

  • @harisimer
    @harisimer 8 часов назад

    you could see a horizontal pattern at i and a vertical pattern at j
    so chinese remainder theorem for *result mod 103 = i* and *result mod 101 = j*

  • @huw2904
    @huw2904 4 часа назад

    > The problem is you cannot print out like 7000 grids.
    Oh but you can!!

  • @infosec-gq4wf
    @infosec-gq4wf 5 часов назад

    2 eroor