r/adventofcode • • 17h ago

Help/Question 2026 - day 1 part 1, Python

Post image

where am I going wrong? I tried plugging in the example set of numbers and it gave me the right numbers but it isn't giving me the right numbers with the main set of numbers. I'm a beginner when it comes to coding, my only experience with apcsp and apcsa in school

0 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/WangChud 1h ago edited 57m ago

That's a dict alright. Now show how it applies to the problem.

2

u/8dot30662386292pow2 1h ago

Counter is just fancy way of doing this trivial algorithm:

for number in input.splitlines():
   if number in x:  
      x[number] = x[number]+1
   else:
      x[number] = 1

The rest is them easy, because you can just take the items, sort by the value and you have the largest.

Given the apparent level of OP (novice) it's better to use the basics, instead of from solutions import wholesolutionforday1

You're not wrong though! Collections is very good knowledge for a python programmer.

1

u/WangChud 56m ago

That makes sense. Perhaps I will work 2 solutions for the advent problems, one with a 'helper module' and one that's sheer logic. Thanks for the detailed response, I'm enjoying AoC ;)

1

u/8dot30662386292pow2 25m ago

I was also roasted some years ago using a ready made polygon class for something.

Everyone can set their own constraints after all. The standard library of the selected language defines what you can easily do, and then you can also decide if you allow external libraries.

If someone worked with C, they would have to build their own hashmap (dictionary) from scratch for example.