Not sure where @RedNose is so I'll just post this. Post ur solutions below or whatever idc
Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!
Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app
What did you think about today's problem?
Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)
Jump in the discussion.
No email address required.
Did you guys do it the dumb way or the smart way
Jump in the discussion.
No email address required.
Dumb way is a lot faster to write than solving the equation. I still haven't yet placed first out of the dramafriends doing the challenge, and my competitive ambition must be sated
Jump in the discussion.
No email address required.
More options
Context
You need to read N chars, so obviously is O(N).
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
i didnt even finish yesterday. i give up. i cant give a frick anymore because LLMs have ruined fun and this is not fun this year because the entire point of this year is fricking LLMs,which means making the problem texts as obtuse and r-slurred as possible. i havent even read todays problem and im not going to because yesterdays was so egregiously stupid for a day 4 problem. suck my frick, eric.
Jump in the discussion.
No email address required.
just regexmaxx
(i say this without having done yesterday's monstrosity)
Jump in the discussion.
No email address required.
More options
Context
Hitting this year without having done prior problems would be a massive brick wall, I can pattern match to what it's asking but you have to know what's up to do that
E: he's coping about not writing to LLMs but idk if I believe him https://old.reddit.com/r/adventofcode/comments/18bp8id/comment/kc646i4?context=8
Jump in the discussion.
No email address required.
More options
Context
its a fun little problem solving exercise. if u are trying to be competitive that's meh, for me its just a test of my own skill.
some people on here are writing about it like the point is to get a tech job. i mean if that's what u gotta do, fine, but any half-decent tech company is going to know that being fast at solving programming problems doesn't make you a good software engineer, in fact, it might make you a terrible engineer. the code I write for AOC is purposefully terrible because I'm just having fun with it and don't expect anyone else to ever need to modify it or deploy it
anyways don't take any of this too seriously, if it appeals to you do it, if it doesn't appeal to you don't do it. ez
Jump in the discussion.
No email address required.
More options
Context
Good decision of me to not take part this year
Jump in the discussion.
No email address required.
More options
Context
More options
Context
The input parsing is really bloating my code. Much easier than yesterday and part2 runs fast enough(2s) that I am wont bother doing fancy math.
Jump in the discussion.
No email address required.
jfc why do people use C++? input parsing in JS is really ez:
repeat for the distances and you are done.
Jump in the discussion.
No email address required.
Agreed that it's a shit language but it could be written more tersely.
For parsing you could do this:
And that's not even using the more modern features of cpp 20.
The full solution ends up not that far off from other compiled languages:
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I stored each win and how long you'd to hold down the button separately before, thinking that might become useful in part 2, it didn't. If I remove this and instead just count how often you win (and actually enable release mode), i am down to 29ms.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
There's also the analytic solution, where t is the race time and d is the race distance.
Jump in the discussion.
No email address required.
Huge pain in the butt that some roots are ints so you can't just round. Guessing this is where they expected to trip people up.
Jump in the discussion.
No email address required.
More options
Context
yeah I did this first and considered not even writing the code for it lol
I shouldn't have waited until I got home to start I could have done this on a notepad
Jump in the discussion.
No email address required.
More options
Context
If you didn't feel like remembering how to do math, you could also recognize that the winning numbers are always a parabola with the highest point in the center, then just divide the time by 2 and test backwards until it isn't big enough anymore, then multiply the result by 2.
Jump in the discussion.
No email address required.
I mean just brute forcing it took less than a second on my shitty laptop.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Cancel your negatives, please
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Pretty easy puzzle today.
Jump in the discussion.
No email address required.
Oh you guys did it like that? I solved the inequality like an r-slur.
Jump in the discussion.
No email address required.
I was going to do it but the brute force finished quick enough
Jump in the discussion.
No email address required.
I saw the big numbers and didn't even try bruteforcing, meanwhile sweating over solving shit I haven't looked at in 15 years
Jump in the discussion.
No email address required.
wish i knew what u r-slurs are talking about
i cant do shit outside of a for loop and if/else
Jump in the discussion.
No email address required.
This shit:
Jump in the discussion.
No email address required.
More options
Context
Did you not do quadratics at school? "negative b plus minus square root of b squared minus 4 a c all over 2 a" is seared into my brain for life.
Not that it mattered, you'd spend minutes writing efficient code for a ~2 second perf boost.
Jump in the discussion.
No email address required.
hmm is it even a performance boost tho? I thought computers suck at division. Or u mean like the xtra computation to derive the answer is less than trying to stick with +-*
Jump in the discussion.
No email address required.
They do, but one equation gives you the solution so it's basically instant. Also the division is by -2 which could just be a bit shift. I think even a binary search brute force would be slower (I cba to check).
Jump in the discussion.
No email address required.
hmm here's what im getting seconds:nanoseconds
idk what thead op's language is tho but id be curious to compare
e: absolute dogshit for the 2nd part lmfao 16 seconds
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
I did but I forgot nearly everything I learned because I don't use it :\
On one hand it's a quick study session away from being usable info, but then also a few days of not using it away from forgetting it again.
And I do remember that specifically the forumla itself is seared in there but outside of solving for possibilities for x³ + 2x² + 8x or whatever Idk any practical use
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
!codecels
Jump in the discussion.
No email address required.
More options
Context
If they wanted people to solve it the clever way using quadratics roots they should've made brute forcing less appealing
Jump in the discussion.
No email address required.
The 'clever' way is still much easier than most other days
Jump in the discussion.
No email address required.
More options
Context
More options
Context
What genius put the range-splitting question on day 5 and this on day 6?
Or if you wanna be a nerd and use quadratics:
Jump in the discussion.
No email address required.
More options
Context
Are we supposed to be voting based on the difficulty or the quality/fun of the problem?
Jump in the discussion.
No email address required.
I thought it was difficulty and I've been rating them all 1/5 to look smart.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Advent of code is so r-slurred
Just sexy Indian dudes doing generic tasks so they can brag on LinkedIn.
Yea bro google will notice yu spent your xmas indoors doing pointless code
Jump in the discussion.
No email address required.
Let people enjoy things!
Jump in the discussion.
No email address required.
More options
Context
It takes like 20 minutes and is a fast way to explore a new language, plus you get to have fun and share it with other people, see solutions you wouldn't have thought off, learn idiomatic expressions, ...
It has better examples than most official docs.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Thanks babe I got stuck in a meeting
Jump in the discussion.
No email address required.
More options
Context
I'm sure a search is a worst-of-both-worlds middle ground, but it's fun to regurgitate from memory
Jump in the discussion.
No email address required.
More options
Context
this one was so much easier
Jump in the discussion.
No email address required.
More options
Context
Jump in the discussion.
No email address required.
@transb-word stop exiling people pls bb
Jump in the discussion.
No email address required.
twas a joke before christmas
Jump in the discussion.
No email address required.
ok then
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
part 1 is here
for part 2 I just plugged the coefficients into wolframalpha I'm not coding the quadratic equation lol (and didn't want to spend time thinking about rounding errors)
Jump in the discussion.
No email address required.
This did seem like an unusual puzzle for advent of code with the tiny input files. You don't really need to program much to solve it. They usually make the input so long that there's no way you're going to do it by hand.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I like this
Jump in the discussion.
No email address required.
ikr! bing ai image gen
Jump in the discussion.
No email address required.
More options
Context
More options
Context
lol, lmao
Jump in the discussion.
No email address required.
More options
Context
Solve each race in O(1) using highschool math
the distance you can travel is given by d = p(T-p), where T is the total amount of time, and p is how long you hold the button. (This is just d = v*t, but the time you have is also dependent on the velocity)
This forms a parabola with zeros at p = 0 (so you never press the button) and p = T (you never let go). Naturally the optimum is at T/2.
next find the p that corresponds the record distance. So do r = p(T-p), where r is the record distance. You'll use the quadratic formula and get two big equations which I won't type out here.
finally ge the distance between both values of p using subtraction. if you do this the terms cancel out and you are left with sqrt(T^2-4r). This is (pretty much) the value you are looking for
(You'll need to do some small adjustments but they are uninteresting)
Jump in the discussion.
No email address required.
More options
Context
This was just basic math+avoiding integer overflow
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
That Marsey looks kinda Downsy.
Jump in the discussion.
No email address required.
More options
Context
Pretty straightforward, nice break from yesterday.
Jump in the discussion.
No email address required.
Got this for n°1, n°2 done by hand:
Wish I had known about prod lol, couldn't find it in the docs because I was searching "mul".
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I was hoping for a twist with how easy part 1 was (I noticed several patterns with the output) but nope
Jump in the discussion.
No email address required.
More options
Context
Jump in the discussion.
No email address required.
More options
Context