Come to think of it, a pipeline that feeds the problem text into an LLM to generate a solution and automatically runs it on the input and attempts to submit the solution, doing this N times in parallel, could certainly solve the first few days' problem in 9 seconds.
A problem that wouldn't be immediately solvable by LLMs would either be too advanced or simply too large to be fun.
This is probably where programming as a whole is going. Many of the things that make programming fun for me, like deeply understanding a small but non-trivial problem and finding a good solution, are gonna be performed much faster by LLMs. After all most of what we do has been done before, just in a slightly different content or a different language.
Either LLMs will peak out at the current level and be often useful but very error prone and not-quite-there. Or they'll get better and we'll be just checking their output and designing the general architecture.
I'm not played counterstrike in over a decade, so you got me wondering - are there matches where everyone uses aimbots? What does the game look like then? I suppose there's a new mix of strategies evolving, with a higher focus on the macro movement planning?
Yes
> What does the game look like then?
I have only observed the games, it requires a lot of hiding.
Most of the time the winning method is to act at the very last second and hope the other player is distracted.
Compare https://adventofcode.com/2024/leaderboard/day/1 to e.g. https://fuglede.github.io/aoc-full-leaderboard/
There was also at least one instance of people working together where you would have 15 people from the same company submit solutions at the same time, which can be a bit frustrating but again, not a huge issue.
Usually this goes for any median which might be in a sneaky bimodal distribution of, say, AI models vs humans. I guess it applies to leaderboards too though.
I can imagine a great pipeline for performance optimization: 1. have an AI generate millions of tests for your existing code 2. have another AI generate faster code that still makes the tests pass
So I guess all I want for Christmas is a massive compute cluster and infinite OpenAI credits :P
Later, after being called out on it, they posted an apology to their GitHub profile (https://web.archive.org/web/20241201064816/https://github.co...): "If you are here from the AoC leaderboard, I apologize for not reading the FAQ. Won't happen again."
Both the repo and that message are now gone.
2015 - 10:55
2016 - 7:01
2017 - 1:16
2018 - 1:48
2019 - 1:39
2020 - 7:11
2021 - 1:07
2022 - 0:53
2023 - 2:24
And this year's second place was 0:54.Personally I don't do it to compete, I just like puzzles.
In particular the LLM cheating isn’t just by conjuring a solution: humans don’t get ASCII characters pumped directly into their brain, we have to slowly read problem descriptions with our eyes. It takes humans more than 9 seconds to solve AoC #1 purely because of unavoidable latency.
RIP Advent of Code.
Perhaps there is a scope for an alternative AoC type competition aimed at AI submissions...
...though of course that would be experimenting to get us all out of work. Hmm.
I didn't realise it was be timed, which is good because I casually set up a new rig to give future puzzles some kind of rig. I used C# which, although probably more wordy than other solutions, did the job and LINQ made light work of the list operations. Ended up with about 6.5 minutes for each one but most of that was refactoring out of pedantry.
Either that, or there were hundreds of people trying and none were able to get it working despite the basic problem. I like to imagine most people reading the rules and being a good sport.
But, yeah, don't use LLMs to try and get 9 second solve times on the public leaderboard, it's not in the spirit of the thing and is more like taking a dictionary to a spelling bee.
> Here is how platforms die: first, they are good to their users; then they abuse their users to make things better for their business customers; finally, they abuse those business customers to claw back all the value for themselves. Then, they die. I call this enshittification, and it is a seemingly inevitable consequence arising from the combination of the ease of changing how a platform allocates value, combined with the nature of a "two-sided market", where a platform sits between buyers and sellers, hold each hostage to the other, raking off an ever-larger share of the value that passes between them.
Enshittification occurs when previously good or excellent things are replaced by mediocre things that are good enough for those susceptible for advertising and group think.
Examples are McDonalds vs. real restaurants, Disney theme parks vs. Paris, the interior of modern cars, search engine decline, software bloat etc.
That's everyone, including you, no matter how edgelordy you post about 'normies' and how you are above that. See how quickly your brain hands you "McDonalds" and "Disney" when you need an example.
Yes you just used the first one that came to mind, the one that everyone would recognise, that's because billions of dollars keep McDonalds first in mind and universally recognised. And even if you make your personality "I wouldn't eat at McDonalds" that money is getting you to propagate the name on HN, just to remind people it exists and keep people talking about it.
Obviously if you're doing it recreationally you can cheat with AI but then again that's no different than copying a solution from reddit and you're only fooling yourself. I don't see it having an impact.
I also don't see how it would be possible otherwise.
I think the strategy for the harder puzzles is to still "do" them yourself (i.e. read the challenge and understand it) but write the solution in English pseudocode and then have an LLM take it from there. Doing this has yielded perfect results (but less than perfect implementations) in several languages for me so far and I've learnt a few interesting things about how they perform and the "tells" that an LLM was involved.
i1:("I I";" ")0: `:1.txt;
sum {abs last deltas x }each flip asc each i1 / answer 1
sum {x * sum x = i1[1]}each i1[0] / answer 2
What does each flip asc do?
from collections import *
xys = list(map(int, open(0).read().split()))
xs = xys[::2]
ys = xys[1::2]
xs.sort()
ys.sort()
print(sum(abs(x-y) for x,y in zip(xs,ys)))
yc = Counter(ys)
print(sum(((yc[x])*x for x in xs)))
data = { i+1 : sorted([ x for x in list(map(int, open('input').read().split()))[i::2]]) for i in range(2) }
total_distance = sum(list(map(lambda x: abs(x[0]-x[1]), zip(data[1], data[2]))))
print("part 1:", total_distance)
similarity_score = sum(list(map(lambda x: (x*data[2].count(x))*data[1].count(x), set(data[1]).intersection(data[2]))))
print("part 2:", similarity_score)
I encourage anyone who gets value from this to donate to support it if they can. It is a passion project but nonetheless comes with real costs.
With the sheer amount of sponsors and AoC++ users I do believe that this is not quite a small 'passion project' struggling to pay the monthly subscription to a VPS.
That being said, adventofcode is absolutely great and people should support it if they can. But I do think the author is doing quite well with the amount of support he is currently receiving.
Bit simpler than writing an override or fetching the HTML.
Of all the cynical comments I see on HN, this ranks very very low.
I like to do them in a functional style in Kotlin as far as possible, as that's different from what I do at work.
Edit: Here's mine from today, with my utils it's not exactly plain kotlin, but part of the fun is building a library of sorts with cool functions https://github.com/Matsemann/algorithm-problems/blob/main/ad...
This is also what I like, reading other's solutions and learning new stuff. I browse the subreddit after solving it myself to see all kinds of cool approaches.
https://raku-advent.blog/2024/12/01/day-8-rendering-down-for...
AoC usually loses my interest around day 6 or so, but a PDL journey for the advent sounds a lot more appealing. Time to dust off my Perl skills and see if I find it as fun today as I did back then.
Repo: https://github.com/ArcHound/advent_of_code Writeup: https://blog.miloslavhomer.cz/p/advent-of-code-cli-client-an...
Good luck to y'all in 2024 and enjoy!
Normally I'd break out Python for this, but given the constraints maybe I should try to see how far I can get through this in Excel. It'd be a fun little challenge :)
(I think you could even use typescript with this method with the on the fly babel transpiler (you just include a script tag) but I haven't tried that.)
For the pythonists around here, give F# a try: it can feels very close to scripting and it has a wonderful REPL too :)
And after providing detailed answers for so many times, I don't think it's worth it.
For AoC I don't use a real project setup, just a `dayX.fsx` file and I run it like a script with `dotnet fsi dayX.fsx`, et voilà :)
Wishing everyone a fun challenge. This year I will be practicing F# and hope some of you will give it a try too :) https://github.com/neon-sunset/AOC24/blob/master/day1.fsx
they have part of the site that has lessons for developers:
https://app.codility.com/programmers/
I haven't used it for a long time, but they also have contests with some small prizes: https://app.codility.com/programmers/challenges/
With leetcode you’re off in the woods by yourself. Stuck on a problem? Here’s a cold write up. Finished a problem? Do another, monkey.
I’m never gonna do it fast but I enjoy using fparsec to get the input text in whatever format I need each time, even if writing and debugging the parsers sometimes takes up way too much of my time!
Then once you do get that context... like LeetCode problems often aren't very inspiring? A lot of the time it's "just apply this technique here".
Whereas in AoC, at least in the first few weeks, it's mostly just, do the task, attack it from first principles.
The use of “pretty far” gives them a bit of an out, but I think this statement is a little disingenuous. Last year, at least, a bunch of the problems needed fairly sophisticated algorithms to find the solution in a reasonable amount of time.
To me, a little programming knowledge is what somebody who is six weeks into their introduction to programming class has. They know variables, loops, lists, and maybe associative arrays.
Fortunately it's never been needed. Every time it's come up the problem has been solvable with high school algebra level math skills (you need to know what the lcm is and that's covered in middle school in many places). If you knew the CRT you could jump straight to a solution, but a solution was easily derived using algebra and a couple loops.
It's more like a set of logic puzzles. Programming and algorithms are only incidental.
https://github.com/NoelJacob/advent-and-other-calandars Compiled by myself.
I think there's a few of these for different languages/tech. I think they may be good for HN'ers seeking some kind of little daily advent-y fix without the potential emotional/mental investment of AoC.
I've promised myself that one year I will move beyond the first seven prompts ... who knew creativity could be so taxing?
For me Advent of Code is a slippery slope. The difficulty ramps up so at first it's easy, then it's rewardingly difficult. But then before I know it, it takes wayyyyy too much time. The danger is being emotionally invested by then.
So it's not linear, and also based on your own knowledge. So perfectly fine to skip some days and still it's possible to solve some of the next ones!
You try telling that to my brain. That guy doesn’t listen to me.
One common AoC trick is that you can brute-force part one (e.g. O(n^2) complexity or worse), but part two scales up `n` to make that intractable.
*ignore my sloppy conflating of concurrency and parallelism
And by design, every problem is solvable on decade old computers in a reasonable amount of time (seconds) so parallelism is great if you're looking to minimize the runtime, but it's never necessary.
That said, if you'd have a better holiday season by just stepping back from the computer and relaxing then that sounds great too. Either way - enjoy!
Every year except for one has been kind of the same pattern for me:
Day 1: this year, I'm just going to solve the problems. No futzing around.
Day 3: but it would be kind of neat to turn the solutions into a reusable AoC library. Just something minimal.
Day 5: and I should really add a CLI harness for retrieving the problems and parsing the input files.
Day 6: and testing of course.
Day 7: maybe I'll skip today's problem (just for today) and keep improving the framework.
Day 358: oh neat, Advent of Code is coming up.
But I luckily managed to avoid the "reusable AoC library" problem around 2019 when a week beforehand I wrote down the sort of functions I wanted to have at my disposal (usually things around representing 2D/3D grids of unknown size and pathfinding/debugging therein, but a few other bits and pieces) and made a simple library that I will sometimes add things to after I'm done with the problem for the day.
I was tempted to some functions (similar to those your CLI harness provided) for retrieving test data and submitting answers but I managed to stop myself short of that! But I am sure you're far from the only one to end up down that road.
If it's a weekend I'll just do it at my leisure at some point during the day when I have some time - maybe head to a nice cafe or something.
I'm nowhere near the top 100 - closest has been iirc top 200 a few years back - so it's not like I need to start at 6am.
Midnight would be much more acceptable.
I’m not seeing my name on a leaderboard any time soon.
Ended up at around spot 6500.
Boggles my mind to even imagine what it would take.
I can move that fast, faster even, when I know exactly where I'm going.
I imagine if I was doing this kind of problem solving all day every day it would be possible.
I have no interest at all in competitive programming or maths; I spend 40+ hours a week doing programming for work, I want games and challenges that pull me away from that so I continue to have a life outside of my job.
I've done it (and completed it) the last five years. I used it to try out a few languages (Haskell, Idris, Lean) and did it in python one year I was feeling lazy. I've got a project going now, and I probably should do that instead.
However, that project is a programming language, so this is a way to test practicality. But solving problems and fixing shortcomings in the underlying language at the same time may be a bit too much. (It's a dependent typed language, so there is a lot of subtlety to deal with.)
For instance I’m using it this year to dial in new neovim configs. Last year was to get comfortable with a split keyboard.
Some time ago I started creating mods for the game stardew valley. It still involves some programming but mainly drawing, creating animations and composing music! It's an absolute blast and so relaxing (like the game itself).
I think by now I could even start working on my own game but I don't yet have a desire to.
For more complex things C# is needed as Stardew Valley is made with XNA/MonoGame. There is a NuGet package to set it up which even includes hot reloading of the mod into the running game: https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildC...
I use NeoVim but you can use any editor. It was a bit of a pain to get dotnet going on arch linux but I got it working after some tinkering.
To get started, one can install SMAPI, then unpack the game assets. Then, you can open game maps and assets in the Tiled level editor. I also use Aseprite to make the pixel art tilesets for the maps (LibreSprite would also work). I use a mix of my own tiles and tiles from the game itself for my maps. Music and sound can also be added or patched with ContentPatcher. I make all sound related stuff with Ableton Live. I haven't done much with C# yet but SMAPI provides a pretty nice API so it should be pleasant to use.
Sounds very fulfilling, but I explicitly want to stay as far away from tech as possible outside of working hours. I'd much rather draw and compose music outside of any tech environment.
Plus, creative hobbies are an amazing way to connect with people, it's half the reason I like them. Tech hobbies are going to make me connect with tech people which isn't what I want: I meet enough tech people at work, I'd end up talking about tech (languages, frameworks, software, AI...) outside of work which have no interest in, and I don't really relate to tech people anyway (as a sweeping statement that obviously isn't an absolute)
At best, I tend to set myself an upper limit for runtime.
Note it's a single-use game.
https://boardgamegeek.com/geeksearch.php?action=search&objec...
(I don't see any reference to leetcode, but people can approach Advent of Code however they like. I'm certainly not waking up at 5:50 to race for a solution.)
My daily grind is like carefully scaffolding and repainting a 50 storey office building made of typed, modular, spaghetti couples Python ML code.
AOC in ipython, by comparison, is like doodling pictures with a brush pen!
It is very enjoyable and also why leetcode is a little silly for interviews: convince me you can I want to know a candidate can flawlessly paint several hundred square feet of wall, not doodle a cat cartoon.
(Or, away from the analogy, the software equivalents. Can you safely progress business goals as a member of a team on a legacy codebase that’s partly evolving on the cutting edge and also partly rotting on the trailing edge? I don’t care if you can build a naive implementation of our trading system… sorry I mean an Elephant Auction… in 90 minutes!)
If you have never tried it you should definitely give it a go. It’s quite enjoyable at a moderate dosage.
The problem with continuity across days is that the later days can be blocked by the earlier ones, as they were in 2019. That partly defeats the purpose (or structure) of the challenge, where you can mostly pick any day and try it without regard to earlier days or prior years.
I thought the IntCode thing was great and I hope to see something like that again this year.
After I solved it I looked at other people's solutions and they used Meta's proposition solver in about 10 lines. Seemed like a massive cheat to me.
My script still says "TODO: find a real solution". Good times.
Which one was the "graph-cut puzzle" ? I've had a few where I couldn't do them on the day, either I was busy or I found them harder than usual or sometimes both.
It looks like in 2023 I took until almost New Year's Eve to finish, but until like the 21st of December I was fine, I got thrown off by travel and other commitments in the last few days as they got more difficult.
+/'{x:".",x;H:(-1+;1+i-)@'+|\m*i:!#m:x=\:"#."
R:(x=x)({[h;d;x;y;z](z#0),+\(((-z)_~"#"=x)&z_d>z)*(*y),(-z+1)_y-0^y h}. H)[x]/y
(*|R)-R@*|0,&1_*+m}.''1({("?"/:5#,x;,/5#,y)}.')\@[;1;.:]'" "\:'0:`:i/12.txt
https://ngn.codeberg.page/k/#eJxVjsFugzAMhu95iiyWik1CIGPtIVG...
I think as nerds we need to be quite careful not to get too drawn into this kind of thing. Sometimes it's like a superpower, but other times it just pointlessly consumes your life. Kinda makes me think of gambling addiction: "when the fun stops, you stop".
It's totally worth it, though, especially for the first week, when you look up how other people solved the thing you just solved. I always learned (or re-learned) something from that. IMHO there's not that much value in looking up solutions before you solved it yourself, though.
What line of work are you in that you can take a winter break, and furthermore, that you can actually not work during that break? I'm envious...
I've always wanted to do AoC but on top of work it is too much.
PRevious years I've managed basically the entire month of December.
I always have holiday days left over at the end of the year to take.
I love what Advent of Code does, but when your site is all text, there's just no excuse to not let the user resize it by default.
If there is a community for those who use other rules to compare actual solutions instead of answers I would be interested to hear about it.
I am coming from low level C++ gamedev side so I understand that most people here use different tools to solve different problems.
Looks like it is for young people who have dedicated time for it everyday.
Personally I would like to do anything like this with no time limit and probably no monetary prizes. I think the only value of those puzzles is to fire up rarely used neurons that hopefully are still there after another year of shipping corporate products xD. I might appreciate fresh point of view from young people and new programming languages though.
There are plenty of professionals with jobs and families making time for AOC because they enjoy it. Doing the problems at the same time as everyone else is a VERY different experience from doing them whenever you'd like.
If you don't want to make the time for it, power to you. I'd recommend most people to drop off after the first 10ish days. But don't delude yourself by ascribing this as the domain of "young people" or those without responsibilities. You're making a decision. Own it.
Imho: I worked with code that has long history for my entire career. If the goal is to look at some objective quality of solution then I do not believe in time limits. The longer I work the more things getting patches/updates/remasters and value of better code goes up and value of arriving at any kind of solution overnight goes down.
The thing about AOC is that it's really less about the code that you generate, and more about the process of solving the problem. The challenge is really what you make of it. Some people will golf it, some will go for speed, other for performance, etc.
That's why it's so different to solve the problems in "real time". There's a huge community of people solving the same problem that you can interact with and bounce ideas off of. Even just a few days after the problem is released, most of that active discussion has dried up, so you can no longer participate in that discourse.
So, again, I don't think there's anything wrong at all with what you're saying, but there are other elements to consider beyond maintainable code and pristine solutions.
I agree and I happen to think the experience of doing it later than everybody else is significantly better. If I search for “AoC 2024 day 12 hint”, I’ll get better results on Jan 12 than Dec 12.
If your goal is to compare solutions, lots of that happens on the subreddit for it where people post solutions in their language of choice on the daily threads.
I just do it for fun. When I was younger I'd actually do them at release (11pm in my timezone), now I don't even bother and just used them as sort of a brain teaser to start my days and compare with coworkers who also do it, a lot of us in different languages.
However, there are other ways to rank yourself against others. You can order your private leaderboard by number of stars, or make your own leaderboard using their APIs.
Generally you have the main community on reddit (memes, questions, daily thread for sharing solutions), then the language specific subreddits or hosted forums where you will see solutions discussed and shared, plus a couple of new users asking questions.
Also, within the daily main community thread you will see the niche sub community of people posting their code-golfing attempts.
The subreddit /r/adventofcode contains discussions of solutions with lots of different skill levels.
I've done AoC for five years to learn new languages and try solve all of them myself during the month of December. (Dunno if I'll run the whole thing this year - I have another project.) Others try to get on the leaderboard, and some will implement solutions that they've seen sketched on reddit.
Last year a few people used Z3 for one of the problems, and I went back and tried that to get some experience with Z3. And I've occasionally gone back and tried another approach or new trick that I saw on the subreddit. (In the years that I've used Lean, I've sometimes gone back and added proofs for termination or array indices, too.)
Ada took me somewhere between 90-120 minutes, whereas I had the first problem done in JavaScript in about 30s-60s, just for verification.
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
procedure main is
Left : Integer;
Right : Integer;
begin
Get(Left);
Get(Right);
Put(Left);
Put(Right);
end main;
If you give it any of these pairs it'll work as expected, put it in a loop and you'll get all of them: 1 2
3 4
5
6
Sometimes thinking about lines is a red herring in AoC, the lines often don't matter, only getting each value into the appropriate collection (a pair of vectors in this case since you don't know the size). For the counts, you can use a hashed map, they're built into the standard library. If you learn to use them now that'll help you out in later days, they're a commonly used collection (for me) in these challenges. with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
procedure main is
Line: Unbounded_String;
begin
Line := Get_Line;
Put_Line(Line);
end main;
https://learn.adacore.com - good source of tutorials, unfortunately a lot of the better learning materials beyond this are books, not online tutorials.I've found especially as the month progresses it's just as much Advent of Reading Comprehension as it is coding :)
Edit: Someone else posted an "Advent of " list which included https://adventofsql.com/, perhaps those problems will be a little more pedestrian for SQL.
I realized when solving todays problem that SQLite’s
json_each("[" || T.c1 || "]")
Is useful for parsing comma separated rows into (row, col)-pairs as well.EDIT: nevermind, found it! https://github.com/ruuda/adventofcode/tree/master
Doing it in a Lisp I’ve been writing in Ruby will have me giving up even sooner, but it will be fun!
https://gavinhoward.com/2024/11/advent-of-code-2024-getting-...
It's not half bad at this kind of twiddling for being a statically typed mainstream language.
https://github.com/codr7/aoc24/tree/main/swift/Sources/aoc
This year is a tiny bit weird, I was just getting ramped up organizing the event at a new job; because I think it's very useful for devs to learn some real problem solving, as opposed to stitching frameworks.
And then I had to leave because my new boss turned out to be someone I couldn't imagine working with.
Guess it'll be just me and Emacs as usual.
The language has been moving pretty fast though, I have a feeling a lot of features I find useful are relatively new.
It’s Foundation so hopefully also on Linux/Windows, but if not there’s also one on GitHub called SwiftScanner.
1: https://developer.apple.com/documentation/foundation/scanner
That is if you have nothing against using VSCode.
But no, last year I lost all momentum on my side projects and my gf thought she'd lost me to the elves.
Completing it on time was rewarding but I can't go back.
But I can hear those elven bells a jingling...
FYI trying to solve the problems as fast as you can is not considered "the correct way". The author has emphasized multiple times that going for the leaderboard is not for everyone and requires a pretty questionable coding style. The main goal is to have fun and learn something new.
I tried doing it in Assembly two years ago, ended up spending hours and hours writing an Assembly standard library, then gave up and switched to Rust...
https://git.sr.ht/~q3cpma/aoc2024/tree/master/item/01
If you could post a repo link so I can look at some of the progress, I'd be grateful.
https://www.musixmatch.com/lyrics/Kraftwerk/Boing-Boom-Tscha...
Remember that brute force is also a solution in the AoC; had plenty of fun using SBCL to crack some problems where Pythonistas had to be clever, last year =)
- you can implement a hash table in C in about 125 LOC and reuse it.
- hash tables are not the only way to solve problems. hammer/nail
Only if you write/read your table in two separate passes. A tally needs mixed read/write to increment a counter, not just insertion, so it must be kept sorted during the table creation. Some kind of tree or linked list is probably better in this case.
> you can implement a hash table in C in about 125 LOC and reuse it.
I know. Anyone who uses C and never made at least a basic FNV1A/bucket-based hash table must be insane. But I wanted a small self-contained .c here and have become allergic to (void *); if I were to use C seriously, I'd fix it using a better preprocessor (à la https://github.com/etwyniel/c-generics).
> hash tables are not the only way to solve problems. hammer/nail
Eh, a tally seemed the most intuitive way for the 2nd part.
Insert each element in its sorted position. It will only degenerate if there are many more inserts than lookups, in which case a hash table would do nothing for you.
This could also be a good case for a radix structure.
> void* hash table
I would stay far from poor implementations of high level languages. Why use C if you want generics?
A reusable hash table can be implemented by implementing open addressing with 64 bit integer keys. Then if you have a fancy type you write a hash function and perform linked list chaining on the values.
Another way is to treat the keys as byte arrays.
> seemed the most intuitive way for the 2nd part.
Intuition is a kind of familiarity. There is no reason to learn C if you just write the techniques you already know in a less safe and more verbose way. You instead should be learning a new way to think about problems.
Last year I solved all the problems in C without external libraries [1] and I enjoyed it a lot. It forced me implement some low-level stuff that I had forgotten how to do (e.g. a heap) and to write some numerical routines myself (easier than you'd think!).
[1] https://github.com/sebastianotronto/aoc/tree/master/2023
This year the Amiga has an 060 upgrade with an MMU, so perhaps I can figure out how to use that and have another go.
I say it in jest but that's actually how I used to program a few years ago when I was working on large industrial pieces of software with long compilation time. You just have to be careful and check what you wrote before sending it to the machine.
I think "iterative" programming has made people really complacent when it comes to silly errors. Slowing down can often do wonder.
Not unworkable, but not the most relaxed environment for fast’n’fun cowboy coding. You typically have to reboot a lot.
I think I'll follow in your footsteps. STM32F7 with 320k but with bare metal Rust :)
Well, awk suffices to write a first-person shooter: https://news.ycombinator.com/item?id=34442528
I remember one of my naive brute force solutions from last year ended up allocating gigabtyes of memory. There were obviously more efficient solutions, but some of the inputs are pretty large and so hefty allocations might be difficult to avoid.
I do allow myself a 5Gb disk to which I can page out memory.
Everyone’s different, and it sounds like AoC isn’t for you, but remember not everyone is you :)
So if some activity [work] doesn't contribute to your ability to never have to work again [retirement], you shouldn't do it?
What if I've retired, am I allowed to do AOC then? Or then does the first rule of, only do something the future you would be proud of apply?
What if all of the things I'm proud of are just a false sense of accomplishments? How do I know when I'm actually allowed to be proud of it, or if it's just a false sense of pride?
Like car accident?
https://blog.adacore.com/announcing-advent-of-ada-2024-codin...
curl "https://adventofcode.com/2024/day/$DAY/input" --header "Cookie: $(cat .token)" > input.txt
#!/bin/sh
set -e
curl "https://adventofcode.com/${YEAR:?}/day/${DAY:?}/input" --cookie "session=$(cat .token)"
then: YEAR=2024 DAY=1 ./aocdataPretty good tbh
https://www.kylheku.com/cgit/advent/tree/2021
Give it a try. The structure and recurring themes in these solutions could be used as a source of ideas for how to get started.
The main exception is 2019's Intcode VM/interpreter which was used over about a dozen days (I mentioned it elsewhere, he hasn't done anything like that since). Occasionally, beyond basic algorithms there is some continuity between 2-3 days but that's not terribly common, I don't think there were any pairs of puzzles like that last year or the year before.
If you want to make one code base, you'll still have 25 or so separate solutions. You might have some continuity with common algorithms (like A*) that get used a fair bit in search problems or abstracting out the input handling when you identify common structures for parsing.
Perhaps if you aimed at global leaderboards it would be different, but that's neither my league nor I see any fun in that - getting there requires serious effort and preparation in things that aren't directly related to solving intelectual puzzles.
I find no particular pleasure in using an everyday language like Python for it, because as you said it's too easy.
I have used Haskell, Racket, and in some easier cases APL and it's been fun. Treating it more like a puzzle than an actual programming assignment.
When learning new languages, it's best to do something that actually makes you think in a different shape. If you know Python, don't do Ruby. If you know Java, don't do C#.
I suppose. I do actually useful projects at work. AoC reminds me of why I personally loved programming in the first place - solving small technical puzzles. I don't like trying to make every single moment of my life "productive".
When I said "useful", I meant "useful to me". I figure I'd prefer to solve some problem to scratch a personal itch, or play some instrument, or make a funny game, whatever. Even spending that time on resting would probably be useful. Solving a technical puzzle is nice, but my point was that collecting stars to finish the advent calendar isn't particularly useful or rewarding on its own, and if I need to be motivated internally to do it by adding some artificial challenges, then I can find more enjoyable ways to make myself busy as well.
But that's just me. I just don't think AoC could motivate me into learning something I wouldn't learn otherwise. It just doesn't provide enough incentive to keep going. Tasks are mostly too easy to be rewarding on their own, but some are too hard to just do casually. I can't imagine spending as much time as I did on it - about 30 hours in total, not counting time spent on golfing and browsing other people's solutions etc. - if I had a regular job at the time, and once you skip days it just becomes a random set of challenges that could be tackled at any time anyway.
It does do: higher order functions and functional composition, monads and monadic comprehensions, records, list comprehensions and iterators.
You are correct that it's not going to "push" you into that direction aside from APIs that are already popular, but it's unfortunate it keeps getting bundled together with Java. C# and Java are languages with differing priorities, paradigm support and target scenarios. There is great overlap, but the differences are significant.
My goal is to develop the muscle memory for the tool so I can write code quickly. I’m still generally thinking through the puzzles, but being able to just write out plain English logic, get code generated, ask for it to be well documented, quickly refactor things to be generally reusable, etc, is just fantastic and how all software development should be done in this day and age frankly. Such an accelerator to problem solving.
The past few years I've decided to stick to the same principle I've used in all of my side projects recently. Either I do something in a new language, or I get it done correctly before I get bored. I've found I can't have both.
Skimming some, the core of Part 1 after people have parsed and sorted:
Python:
sum([abs(x-y) for x,y in zip(left,right))
TypeScript: list1.reduce((acc, cur, i) => {
return acc += Math.abs(cur - list2[i])
}, 0)
Common Lisp: (reduce #'+ (mapcar (lambda (l r) (abs (- l r))) sorted-left sorted-right))))
Julia: sum(abs.(list1 .- list2))
Rust: Ok(zip(left, right).map(|(l, r)| l.abs_diff(r)).sum()
F#: Seq.map2 (fun x y -> abs (x - y)) xs ys |> Seq.sum
APL: +/|-⌿
Haskell: map abs $ zipWith (-) column2 column1
and then all the submissions which don't do anything like this, and have manual loops and indexing and clunky data representations or performance-optimized data representations, etc. etc.This is his entire point: getting to this brick wall is _where_ the real learning happens. When you start scrambling, reading old stackoverflow posts, and breaking out the calculus text book you're pushing the boundaries of what is possible for you.
Body builders don't grow by watching other people lift weights.
Don't see any difference with finding the answers on SO, or in textbooks, and having an AI provide the same.
And at the start, novice body builders will of course watch other body builders to learn how it's done.
Unless you're exceptional you're not teaching yourself anything unless it's by learning from others. Few are the pioneers in any field.
Looking how it's done doesn't equal you doing it. It's apples to oranges. OP was referring to needing to do work in the gym to get results. You didn't get results if you looked at others and did the same in the advent of code etc. You are merely entertaining yourself, but you are not competitive participant. With that approach you'll never be on top.
There are people who use frameworks and people who write frameworks. The first group struggles when there is no official documentation or tutorial on a topic they need. The second group when faced with the same goes through the source code and gets the answers.
Bottom line is the question of what you want to achieve - just go through the problems and be done with them, or deep dive into new topics ans material, to widen your knowledge?
What happens when you dig in and exhaust all your best efforts and still don't find a solution? Are you a lost cause because you couldn't figure it out for yourself? Or are you allowed to be shown the way it's done so you can learn from that?
Many times in my life have I not been able to figure something out for myself, and needed shown how the thing was done. Just because I couldn't do it on my own doesn't mean I wasn't capable of either doing it once shown, or that by being shown I didn't learn anything.
You've spent the last hour trying to curl the 50kg dumbbell and you just can't do it. You walk up to the yolked out guy and ask him to show you how it's done, he picks up the weight and curls it with ease.
At this point its not really fair to say you curled those 50kgs, and you didn't get much out of the experience. Maybe you noticed something about his technique that helped, or he gave you some pointers, but you still can't lift the weight by yourself even with that information.
Now if you instead went back and trained some more at lower weights not only would you get more out of the experience (in terms of growth), but also seeing someone else do it is more beneficial since you can try it again yourself and directly apply what you just learned. Eventually with enough training at easier weights and progressing naturally you'll be able to lift the 50kg weights. But that one curl you're now getting to do for the noobie is in no way indicative of the time and effort you actually put in to be able to do that one curl.
Now if you're instead in a warehouse doing your job moving heavy boxes from A to B getting the yolked out guy to help you isn't that bad - sure you can't do it in the future but all that matters is that it was moved from A to B. If we take that same mindset into the gym we'll get nowhere since the gym isn't about moving something from A to B, it's about making you better at moving something from A to B.
Sometimes being shown the answer to a problem is just what you need to move forward, especially if you are inexperienced. Shown the answer with an explanation as to how you get to it is better.
When you are drawing connections between SO posts, textbooks, whatever you do a fair amount of reasoning yourself.
Now that I think about it it isn't AI specific (more knowledge specific) - I'd say the same if you wait a few hours and then look up the AOC solutions on github. Sure you'll have "solved" the problem but you never spent the time to actually figure out the solution.
> And at the start, novice body builders will of course watch other body builders to learn how it's done.
"Learn how it's done" - not get bigger. This is the important difference. If those novice body builders watched others and learned how its done without putting in the reps themselves they'd get nowhere.
By your logic I would gain absolutely nothing, learn nothing, but either looking up the answer or getting AI to give me the answer. I don't accept that.
Reason being? I've been in the exact same situation. Guess what, I learned different approaches to the problem I could not solve. I improved and can now solve similar problems as a result. Is it cheating? Maybe. Do I care? No. Why? Because I'm not doing AoC for the struggle, I'm doing it for fun, and I know my limits too.
If Claude generates it and it produces correct output for the challenge but is subtly broken on some edge case not in the challenge input, how is it difference from pulling some code from Reddit that produces correct output for the challenge but is subtly broken on some edge case not in the challenge input?
Sure, but then what's the point?
BTW I love AoC for all else
This time I'm trying to do them in Rust and Golang in an effort to either learn to like/tolerate Golang (because we use it at work) or prove my hypothesis that it sucks and never use it unless I have to.
My day 1 rust solution:
cargo solve 1 --
release
Finished `release` profile [optimized] target(s) in 0.05s
Running `target/release/01`
Part 1: 1189304 (95.8µs)
Part 2: 24349736 (120.4µs)
Day 1 clojure solution: lein run 1
running all tasks for day 1
reading input from resources/day01.txt
running day 1 part 1
part-fn: #'aoc.day-01/part-1
took: 5.511375 ms
result: 1189304
reading input from resources/day01.txt
running day 1 part 2
part-fn: #'aoc.day-01/part-2
took: 1.822334 ms
result: 243497365
Code here: https://github.com/whalesalad/aochttps://old.reddit.com/r/adventofcode/comments/1h3vp6n/2024_...
Then 'cargo build --release' took 23.3 seconds.
Commenting out one of the sort_unstable lines and rebuilding gave me a warning, recompiled in 1.8 seconds.
https://old.reddit.com/r/adventofcode/comments/1h3vp6n/2024_...
Another claiming 30μs and 32μs:
https://old.reddit.com/r/adventofcode/comments/1h3vp6n/2024_...
https://github.com/dzaima/aoc/blob/master/2024/BQN/1_fast.bq...
Though it is just a beginning and maybe it is a matter of habit,but I should say, that reading LISP family language is so difficult for my brain.
I have the opposite dilemma to you, I want to learn to like Rust.
Rust to me is what a modern take on a systems language would be. I think it’s substantially better than go.
/s
But regardless of this, the name of the Go programming language is "Go" and not "Golang".
I try every year to optimize for speed in zig: https://github.com/ManDeJan/advent-of-code
I tried doing Rust, but I'm too dumb to figure out if each day should be a module or if I should use lib (I guess?) files for each day and link everything to a main entry point.
Can you share your repo (if public)?
Each day is a new module, this way I don't have to think of new names for part1() and part2(). I can still import code from the rest of the crate if I want with `use crate::`.
If you like this style of structuring the project, you may be interested in the generator I use for it - http://github.com/nindalf/aocgen. `aocgen --day 2` will create these files and save you a bit of time. It will even download your problem input if you give it your adventofcode.com cookie.
Also check out https://codspeed.io/advent/day/1 for other Rust solutions that are aimed at being fast. They all use the same project structure. I wouldn't read the top 20 solutions though, they sacrifice readability and idiomaticity for speed.
Though you shouldn't upload the text and inputs of the puzzles (maybe .gitignore them) as per [0]:
> Can I copy/redistribute part of Advent of Code? Please don't. Advent of Code is free to use, not free to copy. If you're posting a code repository somewhere, please don't include parts of Advent of Code like the puzzle text or your inputs. If you're making a website, please don't make it look like Advent of Code or name it something similar.
- I've spent effort on this, and I want the repository to work in future. I want to be able to clone it and run all the code without having to fetch the input once more, even if the site is unavailable. (I actually do this while benchmarking new hardware).
- I don't think it actually hurts the creator in any way, in my opinion. Here's an example: At least 660 people have uploaded inputs from 2022 (https://github.com/search?q=%22closest+beacon+is+at+x%22+pat...). These files have been up for 2 years. Exactly what injury has the creator suffered because of this? Are there people out there thinking "nah, it's too much effort to log into adventofcode.com, I'll just trawl GitHub repos for inputs and figure out what I'm supposed to do from there"? Obviously not.
So I have a compelling interest, and the creator hasn't articulated a good reason to avoid it. If he's able to articulate a good reason, then I'm willing to reassess my stance on this. He has my sympathy and full support if someone creates a lookalike site with the same puzzles and inputs but different CSS and without ads. That would be messed up. The potential injury is clear - he'd be losing users to the lookalike.
This is a subject of some controversy in the AOC community, but nothing I've read in those threads so far has been compelling. Anti-storage arguments usually just come down to "he's asking nicely so please comply". To which I politely respond that I don't accede to every polite request that comes my way.
I can't compare with Rust though because I've never used it. From a very superficial point of view though, it feels less pragmatic. But since AoC doesn't need memory safety or whatever criteria you have for production software, pragmatism and performance for later challenges are more important than safety.
Which is weird because that is not a thought that entered my mind when I did it for the first time. It was pure fun!
For this one, I learned how to write a basic parser with Text.Parsec and manipulate the tuples with bimap !
It's a very fun occasion to learn a new programming language.
Probably some problems will be impossible with limited RAM (2KiB, plus an optional 8KiB on the cartridge, maybe more if a fancy cartridge is used). But I'll try to solve as many as possible.
Today's was possible, in under 4 seconds, using 4KiB extra RAM on the cartridge.
I want to use it as a test to see how human programming can be improved by an AI, so I wrote the solution for day 1, got the right answer, and then gave my code to ChatGPT 4o to ask it to make the code faster.
My version ran in ~3500 ms ChatGPT's version ran in 140 ms
both worked
A great example of how a common DevOps language program can be improved on by ChatGPT.
My hack-it-out code: https://pastebin.com/PDQhxDc9
Faster code: https://pastebin.com/6xwaVkwq
The hacky code uses slower techniques like:
- Get-Content which adds metadata to every line.
- @() arrays with += which copies the array in memory to a new one-larger memory location for every addition.
- Pipeline overhead e.g. ForEach-Object and Measure-Object.
- Filtering the whole second column for each number in the first column, repeated wasted work.
and it's still in the region of your ChatGPT one.
The faster one addresses these with:
- ReadAllLines() .NET method to get plain strings.
- [system.collections.generic.list[int]]::new() which don't box integers and can grow more quickly.
- plain adding numbers into sum variables.
- Building a hashtable [system.collections.generic.dictionary[int, int]]::new() to count each number in the second column.
- Swapping -split for string split() which may have a tiny bit less overhead.
- no pipelines.
The code isn't completely different, it's the same blocks doing the same things, leaning more on .NET lower levels, and years of experience of the basic PowerShell performance hits.
This year, I shook my head at my framework and rewrote it, but at least that only took me a day (so far). Day one was easy, which also helps. IIRC, last year’s first few days were non-trivial.
This year I'm declaring "Advent of Claude"!
Challenge: Write a Claude custom style to solve Advent of Code puzzles within Claude's UI.
Score: # adventofcode.com stars earned in 2 daily conversation turns.
Fine print: web app artifacts are allowed, including paste of your custom input into the artifact UI; one click only.
Per https://adventofcode.com/2024/about, wait until the daily http://adventofcode.com leaderboard is full before submitting LLM-generated solutions!
Of course, feel free to use ChatGPT custom instructions, static prompts, etc.
Day 1: two stars, https://claude.site/artifacts/d16e6bdb-f697-45fe-930c-7f58b2...
Is there a place where you're blogging this or at least aggregating the links so we can see how far you get with it as the puzzles get more challenging?
I already solved the first problem and it was hard to get things ready, read the file, handle the data, etc. But once I had the first steps done it was easy to solve the problem
Everything is here: https://advent-of-code.xavd.id/
I'm unlikely to finish it all in December (the puzzles get hard and I get busy) but I _do_ love the event.
As of last week there were something around 1024 people who had all 450 stars.
Only started on like day 6 of 2022, but became hooked and had some time early in 2023 to go through the previous years. Once you have a few algorithms canned, it's not too difficult and some themes repeat across years.
It's fun to brush up on stuff you don't touch all the time - actual algorithms and stuff.
Hats off to the volunteers and Eric - I aim to donate every year now - it's a great event.
And here I am doing it in Ruby instead of Java this year thinking I was giving myself a challenge.