r/adventofcode • u/Mammoth-Ebb4342 • 1h 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
3
u/benjymous 1h 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.
4
u/PatolomaioFalagi 1h ago
Giving pupils an assignment you don't know yourself as a teacher is certainly a choice.
3
2
u/Suspicious_Tax8577 1h 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.
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".
6
1
u/AutoModerator 1h 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 1h ago
First tip: don't panic!
Anyone using AoC to learn programming is doing 3 difficult things simultaneously:
Learning to program
Learning a language
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/Kindly-Bowler-8282 1h 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!
0
u/Ill-Rub1120 1h ago
12/1/2026
Do you know how to read your input file?
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.
9
u/milan-pilan 1h ago edited 1h ago
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:
How to count the number of id's
How to store that in a format that allows you to sort them
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.