Day 14: Parabolic Reflector Dish | Advent of Code 2023

Поділитися
Вставка
  • Опубліковано 11 жов 2024

КОМЕНТАРІ • 6

  • @Telepriester
    @Telepriester 9 місяців тому

    I like your videos a lot. thanks for sharing.👍

  • @TheTrienco
    @TheTrienco 10 місяців тому

    For part 1 I was happy with my one pass approach. Making it more generic for part 2 somewhat ruined the neatness. Rolling a column north just keeps track of the next valid destination as it goes, so no nested loops needed (swapping ranges with indexing for clarity):
    int64_t dst_row = 0;
    for (row...) {
    if (grid[row][col] == 'O') {
    swap(grid[dst_row++][col], grid[row][col]);
    }
    else if (grid[row][col] == '#') {
    dst_row = row + 1;
    }
    }
    Still can't get part under 19ms, though. All the copies to keep a history up to the first cycle must be killing it.

  • @dominikm6934
    @dominikm6934 10 місяців тому

    Why there is "-1" in calculating cycle number in part 2 on line 92? Can someone explain?

    • @WilliamYFeng
      @WilliamYFeng  10 місяців тому

      the problem uses 1-based indexing but I'm using 0-based indexing, so cycle 1000000000 is actually cycle 99999999.

    • @dominikm6934
      @dominikm6934 10 місяців тому

      Oh I see ❤ Thank you 🎉

  • @agnesakne4409
    @agnesakne4409 9 місяців тому

    Your explanation is not superb