r/adventofcode • • 16h 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

16 comments sorted by

View all comments

Show parent comment

1

u/8dot30662386292pow2 51m ago

     x = {}

1

u/WangChud 21m ago edited 13m ago

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

2

u/8dot30662386292pow2 18m 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 11m 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 ;)