r/adventofcode • u/Mammoth-Ebb4342 • 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
33
u/milan-pilan 15h ago edited 15h 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:
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.
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.
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
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.
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/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:
Typically each day has an example plus expected outcome in the description of the problem.
If not could you find out what the result is by doing it by hand on paper?
If you are really stuck, you could try just reading other peoples solutions. There is no shame in that.
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:
scanfto regular expressions)Enum.frequencies/1)For future problems, two things you'll definitely see:
2
u/Kindly-Bowler-8282 15h ago
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:
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
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:
Depending what language you're using, some of those may be trivial or rather intensive.
1
u/Ill-Rub1120 15h ago
12/1/2026
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/[deleted] 14h ago
[removed] — view removed comment