Day 3: Gear Ratios | Advent of Code 2023

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

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

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

    Great presentation. Thank you for being concise and clear with your structure.

  • @colehdlr
    @colehdlr Год назад +7

    My method focused on finding then looking around each symbol, then adding the numbers around to a global sum (of course storing their start points in an array so we don't get the same one twice). It may have been worse, but I was very happy with the part 2 lol

  • @NicolastheThird-h6m
    @NicolastheThird-h6m Год назад +2

    Great solution. I made some complicated bs, this is so much better and easier to read.

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

    With any language that has a group-by function part 2 becomes easy as hell. All I had to do was for each number basically save the number itself along with the location of its adjacent gear (after observing that every number only had 1 or no symbol adjacent to it) if it exists. Then group by this location into a map/hashmap, get the values, filter the ones where the amount of numbers is exactly 2, then multiply both numbers on each gear, add them up, profit.

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

    This is such a smart solution. Thank you!

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

    I feel so dumb I did day 1,2 but had no idea how to do this day. Had to cheat and look up the answer

    • @NicolastheThird-h6m
      @NicolastheThird-h6m Год назад +1

      No problem we are here to learn. This isn't cheating as long as you get what he is doing

  • @willzin-da-esfiha
    @willzin-da-esfiha Год назад

    I've created a point struct to store position of a character.
    Then, I stored the number, the positions of its start and end characters. Then I pushed the info into an array.
    I stored the position of the symbols also. Then did some coordinates calc to check if the numbers are in range of the symbol.
    The part 2 was easy since I just changed the code to store only asterisk symbols and check the length of near numbers.
    But I was thinking... It's still slow. I will use an array of buckets to improve near point search, checking only 3 lines for each symbol.

    • @willzin-da-esfiha
      @willzin-da-esfiha Год назад

      Update: the buckets' version work almost instantaneously

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

    I came out with a very similar code.. but mine isn't working 😂. I'll try your code with my input. Thanks

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

    I made a total mess of part two to the point where 'git reset --hard' was the best option. Got there eventually but not an elegant solution at all. The feeling amongst work colleagues is that the puzzles seem a bit harder this year. Let's see how it goes...