r/adventofcode • • 15h ago

Help/Question - RESOLVED Am I cooked?

I need to attempt advent of code for my a-level comp sci that I just started but i'm finding it honestly pretty difficult.

Anyone got any tips for being able to do it easier.

And just any tips to be able to code better at all.

thanks

2 Upvotes

30 comments sorted by

33

u/milan-pilan 15h ago edited 15h ago • Heartwarming

We obviously don't know the rest of the puzzles yet, but maybe to set the expectation: AoC usually has a fairly high skill ceiling. So the absolute majority of people will not be able to solve all puzzles. So don't be disappointed if that happens to you too. Coming back to puzzles later is part of the experience for many people.

Today's puzzle is mostly about being able to break down a task into smaller steps.

Ao you need to figure out:

  1. How to count the number of id's
  2. How to store that in a format that allows you to sort them
  3. How to get the first three items in that list and multiply them

Does that help or do you need details?

Don't shoot for the result right away. Make yourself sensible milestones, so 'first I need to have x, then I need to do y with that, then I need to do z'.

And do those milestones one after another. Actually just do X, then Y, then Z and check the result in between, wether that matches your expectation. Use the test set, not the real input for testing, it's a lot easier to wrap your head around.

That's for both AoC and programming in general. The steps you think in will get larger over time. But in programming one of the most valuable skills in my eyes is being able to plan and do one step at a time. That sounds super easy, but is hard in the beginning.

6

u/Mammoth-Ebb4342 15h ago

Thanks very much
I just about managed today's with a little bit of googling (should have been more specific in my message)

but you have definitely helped me i think what i usually struggle with is figuring out what i have to do and breaking it down into smaller steps

21

u/fett3elke 14h ago

You mention a little bit of googling, like it's a problem. Programming is all about asking the right question and finding the help you need.

4

u/milan-pilan 15h ago

Congrats! Being stuck for a bit is totally normal. Your on a good track.

When people say 'learn to think like a programmer', that's a large part of what they mean. And everybody needed to learn that through practice. All problems can be solved if you break them up long enough. That's what makes it so fun and satisfying.

I would say that's the part AoC is a very good practicing grounds for.

10

u/T1lted4lif3 15h ago

As a mediocre programmer, I can say from past expeirences, past 2 years are the ones i have recorded on my guthib, that the first 10 days part 1 should be doable by everyone that has taken a programming 101 course of somne sort, be it youtube or a bootcamp. If not then really reflect and think if you learned anything in those courses

Part 2 will always be trickier, day 10 was usually my limit.

Always ran into complexity errors for part 2 on days afterwards. couldnt find clever ways of simplifying it into runable things on my laptop.

But part 1 for the days after should be fine for anyone that has completed a programming 101 and some fancy algos+datastructures

3

u/mandradon 8h ago

My favorite are where I overthink part 1 and end up preemptively solving part 2 while wondering why my part 1 solution is wrong.

12

u/Suspicious_Tax8577 15h ago

Start with "Can I explain what Eric (the creator--Hi Eric *waves*) is doing in the "test" version of the puzzle, in English, and break that down into "First I need to do X, then we look for Y, then Z."

If you're reading the puzzle and thinking "Eric, WTF??" That's where your problem is.

Do they teach you pseudocode in A level comp sci? If yes, maybe use that as an interim step between the English and whatever coding language you're using.

  1. You are not cooked. 2. You are not stupid. 3. Try not to let it get to you when some of the nerds in the solution megathreads are code golfing their solutions and solving it in a line of code/making these gorgeous visualisations in the CLI/ making time and space complexity really, really matter by doing it on a Commodore 64/Raspberry Pi Pico/ a potato.

Also, absolutely no shame in googling "how to do [thing] in [coding language]" I have absolutely done that myself this morning as I had a brain fart with syntax, and deliberately do these puzzles in very nearly vanilla nvim, so that Copilot doesn't try to be "helpful".

34

u/topaz2078 (AoC creator) 14h ago

hiiiii

3

u/DenieD83 11h ago

This is always my approach too, I start by "with the example input how can I get to the same answer". I try breaking it down into steps like "ok I'm obviously going to have to add XYZ bits together, and I'll need to be able to order them because the task requires that, and I need to be able to get rid of anything that looks like ABC". This usually lets me make sure I understood the assignment, because some days in some years I've built what I thought was the right solution and got a completely different test answer because I have misunderstood what is needed.

Once it's working and I'm happy, then I try to substitute in the real input and see what breaks.

With experience in this I also tend to think about the obvious pitfalls as I build it, like "Hmm, if the true input doesn't always have 5 digits I should expect that", but there are always cases where I have to fix it, I think it was last year one or two days had the example with like 6 digits then some of the real input included 64bit integers.

2

u/Suspicious_Tax8577 11h ago

It's a very good way to stop yeeting yourself down a rabbithole that's going to end nowhere good.

6

u/benjymous 15h ago

It just takes experience - advent of code is a perfect way to learn to program because they're always guaranteed solvable problems, and you've got a whole bunch of other people to help who are all solving the same problem.

So. Assuming it's today's day 1 problem you're working with.

What have you got? A long descriptive story and a text file with some numbers in it.

I guess the first thing you need to do is write code that reads that text file and turns it into a bunch of numbers you can loop through.

I assume you've already got a particular language you're being taught, so look into that first. File parsing is a fundamental thing, so all languages can do it in some way or other.

Now you've got some numbers you can loop through, what next? Read the instructions again - your code needs to go through that list and find the three most common numbers. So put simply, you need to be able to count and keep track (or, possibly group the numbers together).

One important thing to note with AoC is there'll always be an example given, so the best thing you can do is copy that example data into another text file, and run your code against that first. Test that your code gets the expected answer for the sample data, and you can be more confident that it'll work on the real data too.

And come back if you get stuck.

14

u/PatolomaioFalagi 15h ago

Giving pupils an assignment you don't know yourself as a teacher is certainly a choice.

5

u/Suspicious_Tax8577 15h ago

It is certainly BRAVE. Considering how Day 1 2025 was!!

7

u/Justinsaccount 13h ago

Day 1 2025 is the "Bell Curve" Meme. There were two ways to approach part 2:

  • See that the total of all moves was only a few hundred thousand, and just simulate every single click. This is trivial (a loop, an increment/decrement and some if statements) and there are no edge cases.
  • Attempt to use math to work out what the total should be. This isn't difficult, but there are multiple edge cases.

I wonder if the two parts were reversed if people would have had as much trouble. I think people got stuck after using math for part 1 and didn't consider the "dumb" solution.

3

u/Arctos_FI 9h ago

That was me. Did math for first part and didn't even realize there were some edge cases, then tried to count for some of those edge cases and in the end finally gave up and simulated the whole thing

1

u/fnordargle 14h ago

Just out of interest, did you do anything Comp Sci related at GCSE? I know my kid's school only required a 7-9 in Maths in order to study Comp Sci A-Level, doing Comp Sci GCSE wasn't a requirement (although the school did offer GCSE Comp Sci as an option).

It was billions of years ago (early 90s) but I did GCSE "Information Technology" which wasn't a huge amount of programming, more a general topic covering computers, information and data. It certainly wasn't a requirement for doing Comp Sci at A-Level.

Stick at it, come here for hints (but don't just look at the solutions and copy them) and you should make good progress. I very much doubt you'll be able to complete all 12 days without significant nudging and walkthrough guides (*) but if you keep going you should learn a huge amount, not just about Comp Sci specifics but also about how to learn, how to research things, how to give yourself a chance to find the answer yourself rather than just giving in too quickly, etc.

* I was top of the class Comp Sci nerd during my A-Levels and, looking back, I would have struggled with a large number of AoC problems if I'd been looking at them as a 16/17/18 year old, even if I'd had Google (Gopher and Archie just wouldn't have cut it).

2

u/Mammoth-Ebb4342 13h ago

Thanks, I got a 7 at gcse. My teacher was basically useless though whenever we asked her a question about programming she would just ask ChatGPT the answer, I have just moved to a new school and the teachers are pretty good at helping with this sort of thing just thought it would be interesting to see what the internet had to say about it too.

2

u/fnordargle 13h ago

A couple of things:

Well done for getting that grade and doing what I hope you wanted to do.

Secondly, well done for posting here and asking for help. I've worked in the IT industry for 30 years and I regularly deal with people who just won't ask for help. They spend hours/days/weeks/etc bashing away trying to solve some problem themselves only for someone else to be able to solve it near instantly or point them in the right direction and save everyone huge amounts of time.

(I'm not perfect, I've done it myself, but I soon learned it's far better to fess up and ask for help early. Only idiotic colleagues/managers would look down on you for doing so, and you don't want to work for that kind of person or in that kind of culture.)

One of the key things I'm looking for when hiring people is the ability for them to volunteer when they have reached the limit of their knowledge. Admitting it when asked is second best. Trying to bluff/bluster/bull**** their way through is almost an definite no.

2

u/QultrosSanhattan 12h ago

Define "difficult" by asking yourself those questions in order:

¿Do you understand the problem?

¿Do you have a conceptual solution in your mind?

¿Do you have the steps to implement that solution?

¿Do you know how to write the solution in real code?

¿Is the solution written but it isn't working?

2

u/heijp06 13h ago

A couple of things that might help:

  • If you do not know how to solve the problem as given, maybe try a smaller problem.
  • Typically each day has an example plus expected outcome in the description of the problem.

    • Can you write code to solve that problem? Do you get the correct result?
    • If not could you find out what the result is by doing it by hand on paper?

      • If so, could you formalize the steps you are taking when doing it by hand and turn that in to a program?
  • If you are really stuck, you could try just reading other peoples solutions. There is no shame in that.

    • Can you understand how those work?
    • Could, you after reading a couple, write a solution yourself without looking back at what you just read?
  • And also, what you are doing now is great as well. Reach out to others, people can and will help.

Have fun, programming is great, AoC is great, lots of stuff to learn.

2

u/al2o3cr 8h ago

There's no substitute for practice, but AoC is good for getting that practice.

Day 1 requires several things that you'll see over and over again in the problems:

  • reading lines from a file
  • parsing them - in this day 1 that's just turning them into integers. Later ones will frequently pack multiple pieces of data per line, so you'll want to understand your chosen language's tools for splitting apart strings (everything from C-style scanf to regular expressions)
  • accumulating facts about them. In this problem, that's counting the number of times each number appears. You'll want to look into your language's tools for doing key-value lookup (hash tables are common), or even find a built-in that's handy (eg Elixir's Enum.frequencies/1)
  • post-processing the facts. In this problem's part 1, that's using the appearance counts to find the top 3 and then multiply them

For future problems, two things you'll definitely see:

  • arbitrary-sized integer arithmetic. Some languages will automatically use "big integers" when results get too large, but lower-level ones like C and Rust will require you to be explicit - and sometimes the numbers in AoC get pretty large.
  • two-dimensional grids and "neighbors". Depending on your language, this may be trickier than it looks - for instance, in a language where "lists" are linked-lists accessing the 100th element takes 100x as long as accessing the first and lists probably aren't the right shape.

2

u/Kindly-Bowler-8282 15h ago

You're not cooked, AoC is hard for everyone and it gets harder each day. Few things that helped me: always get your code working on the small example in the puzzle first, before the real input. Work it out by hand on paper if you're stuck. And after you solve one (or give up), read the solutions megathread for that day. Seeing how other people did it is honestly where most of the learning happens. Older years' day 1-5 are great practice too. You got this!

1

u/AutoModerator 15h 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/DelightfulCodeWeasel 15h ago

First tip: don't panic!

Anyone using AoC to learn programming is doing 3 difficult things simultaneously:

  1. Learning to program
  2. Learning a language
  3. Solving a puzzle

You are going to struggle at times, and you are going to struggle on different aspects each day. Everyone goes through this, so don't beat yourself up for struggling at times; stick with it, try to solve things one small step at a time and it'll get easier with practice.

Good luck!

1

u/fireduck 8h ago
  1. Use the language you know best. Advent of Code can be done in nearly anything.
  2. Solve each problem the same way in terms of file names, inputs. Do you want your program reading input from standard input or will it expect a file named 'input' or 'sample'? Whatever, just use the same pattern for each problem.
  3. I find it useful to make myself a library for things you find yourself doing a lot.
  4. Decide how you are going to get help. This is kinda between you and what your school honor code (or whatever allows). When learning new things, I used to hit up google for stack exchange or whatever. These days I use AI. Now AI can happily completely solve these problems, but when I am trying to learn I keep it focused so that I am actually learning. Like for a recent problem in another contest I was having a problem and asked AI, "ok, I have a list that is a few million elements and I keep having to insert in the middle (by index), what data structure might help me out?"

1

u/dantose 6h ago

One of the handy things is that the example data set is usually small.enoigh to do by hand. As you're working through that, think about the things you are doing at each point. These are the same things the code will need to do.

In this case, day 1 the manual way would be:

  1. Count how many times each number appears
  2. Find the top 3 most frequent numbers
  3. Multiply those 3 numbers

Depending what language you're using, some of those may be trivial or rather intensive.

1

u/Ill-Rub1120 15h ago

12/1/2026

  1. Do you know how to read your input file?
  2. Do you know how to store numbers in an array. 3)Do you know how to manually sort numbers in an array?

Create an array for occurrences for each element. Seems like my input is bounded by 1000, so a 1000 element array should work for you. Set all elements to 0.

Loop through your input and read the number. Find the corresponding element in your array and increment.

Now you have an Array with counts. You will also want a parallel array with the value, initialy it will have 0 through 999. Then sort the count list, but even time you need to swap element i and j in your count list, you also make the same swap in your value list.

Once the sorting is finished, your 3 values that you need to be multiply will be at one end of your value list.

============= If you do not know how to sort numbers in an array, a good first algorithm is the bubble sort. Look up, inplace bubble sort.

1

u/Arctos_FI 9h ago

Actually you could just iterate through the value array and hold the indexes of the highest three. No need for sorting.

It just takes it's own kind of logic to keep those variables in order. Like if you get higher than current second highest but lower than highest, you need to first move the old second highest to the side and then place the new one in it's spot

-1

u/[deleted] 14h ago

[removed] — view removed comment

1

u/daggerdragon 3h ago

If you find Day 1 pretty difficult, you are cooked

Comment removed. We do not appreciate you being a grinch, especially when you're being a grinch to a coding newbie.

This is your only warning. Follow our Prime Directive or do not post in /r/adventofcode.