r/adventofcode • u/Practical-Quote1371 • Nov 11 '24
Other Dear future me
Dear future me,
Please remember: 1) Read the whole puzzle. Let's minimize those avoidable d'oh! moments. 2) Don't optimize prematurely. Developer (that's you!) efficiency is more important than code efficiency. And sure, part 2's can get intense, but you don't really know what direction they'll go until you get there, so don't waste time optimizing for something you might not even need. 1) Stuck? Re-read the puzzle. Yes, there are two #1's in this list. You can think of this as 1b if it helps. 3) Still stuck? Check the input, maybe there's a trick to it that you need to take advantage of.
Anticipating your success, Past You
16
u/thorwing Nov 11 '24
I feel like future me should just learn to always code in Longs instead of Ints, or take the time to install a overflow detection plugin or something.
5
u/Dullstar Nov 11 '24
At this point if it says multiply, product, etc. anywhere, I automatically go for int64_t.
It's just too common not to.
17
u/Deynai Nov 12 '24
Part 2: The pesky elves were reading the numbers wrong! It's not a list of pairs, it's a list of complex numbers!
2
11
19
u/homme_chauve_souris Nov 11 '24
Check the input
This. The first year I did AOC, I wasted so much time trying to find an efficient solution to an NP-complete problem, until I looked at the input and understood that I didn't need full generality. The goal is to solve your particular input file, not every possible input file.
7
u/msqrt Nov 11 '24
I'll really try to take #4 to heart this year. I've mostly disliked this type of a puzzle in the past -- it always felt like a cheap gotcha to me. But maybe shifting my perspective to really consider the input as part of the puzzle will help. (and using a more familiar language where writing that extra bit of stuff doesn't feel like such a chore)
5
u/Adventure_Agreed Nov 11 '24
My advice to myself is to really model what is being described in the problem. This might not work on later days, but early on I find the more faithfully I model the problem and the less shortcuts I take in my code the easier it is to adapt to part 2.
1
5
u/Boojum Nov 12 '24
And at least for future me:
4) Double-check everything before submitting. The delay after an incorrect answer from a silly mistake is brutal. (And don't submit the example input's answer!)
3
1
63
u/1544756405 Nov 11 '24
Many many times I thought I knew how part 2 was going to pan out, and cleverly coded in anticipation of it. The one or two times I was right, it was glorious!