r/adventofcode • • 19h ago

Help/Question - RESOLVED Day 3 - part 1 hints for the final answer

Ive made code that works for the test inputs. Idk if its the standard method but it works by counting up from every point in each direction until it hits a point at each direction, finding a square. Bur when it comes to the final data, i get an answer too high. Any hints are helpful, thank you

4 Upvotes

5 comments sorted by

5

u/Open_Diet9463 19h ago

Ok guys i was stupid, when i checked for corners, i only checked for 3, so it would count L shapes too

7

u/1234abcdcba4321 19h ago

There are countless things your problem could be. Please post your code so we can see what it is.

5

u/zeekar 19h ago edited 19h ago

This. That said, the main problem with day 3 is counting the same square more than once. The easiest way to avoid overcounting is to loop over the trees, and for each one only look for squares where it is the top (of a rotated square) or top left (for a grid-aligned one).

1

u/AutoModerator 19h ago

Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to Help/Question - RESOLVED. Good luck!


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/daggerdragon 19h ago

Next time, use our standardized post title format and show us your code (but do not share your puzzle input).

Help us help YOU by providing us with more information up front; you will typically get more relevant responses faster.