I know I'm not the only one finding day 3 frustrating.

My current code for day 3 is here. I find the locations of all of the special symbols, check around them to get the numbers, and dedup the list of numbers I find. To make things easier to debug, I generated some supplementary text files. One shows the input I used, but with all of the numbers I used replaced with 'x's: the output doesn't suggest any problems with my code that are obvious. The other has each number that went into the sum on its own line. I checked a few of these numbers and they seemed correct, but there are too many to check by hand.

What could I be doing wrong? I've officially run out of ideas.

  • snowe@programming.dev
    ·
    edit-2
    7 months ago

    Any given number has a set of “coordinates”. That exact number can’t be repeated, even if it’s surrounded by symbols. But that number might be elsewhere in the list.

    edit:

    here's an example:

    1.1
    .##
    2.3
    

    would give you a total of 7, because 1 and 1 are two different parts in the parts list. But the 1 in the top right is next two symbols, so you still only count it once. It's just a single part! Think of them as parts rather than numbers. Each part is a different thing, even if they have the same name.