13 ms·
Advent of Code 2022 is nigh
- kazinator 4y agoSome AoC 2021 solutions in TXR Lisp: https://www.kylheku.com/cgit/advent/tree/2021 https://www.kylheku.com/cgit/advent/tree/2021
- javajosh 4y agoI did several of these last year and found them deeply unpleasant. I like puzzles but some puzzles are just...bad. Like the ones that require you to just brute force a solution, or write lots of detailed code to capture the requirements...that shouldn't be what this is. Just my opinion, of course, but like I said I found last year an unpleasant chore that felt more like work. Hope it's not like that this year.
- xyzelement 4y agoI recently went through the 2021 puzzles and I don't recall having this experience. I also think the choice of language matters a lot. I did it in prolog a few years ago and it was super concise because you just dealt with pure logic at that point. I can see it be more verbose in Java :) but seriously I find these puzzles hard but not in a chore kind of way.
- deleted 4y ago[deleted]
- bmitc 4y agoAre your Prolog solutions public? I would love to take a look!
- xyzelement 4y agoI'd love to but alas I don't have it public. Googling, I found a few other folks like this one: https://github.com/Limmen/Advent-Of-Code16-Prolog https://github.com/Limmen/Advent-Of-Code16-Prolog Don't know if this is "beautiful" prolog but the programs seem pretty short compared to what a typical AoC question is.
- widforss 4y agoI have only solved one puzzle in Prolog, but here it is: https://github.com/widforss/adventofcode/blob/master/examples/2020/7/main.pl https://github.com/widforss/adventofcode/blob/master/example... I choosed Prolog for that one as that meant I didn't have to implement the search algo, just state the problem in logic.
- kazinator 4y agoThere was one about piecing together data from multiple under-water sensors regarding the locations of mines or something. With the data being rotated in various orientations (in right angle increments) thus having to correlate the overlapping data items. I think it was 19. I wrote quite a log of code to brute force this: https://www.kylheku.com/cgit/advent/tree/2021/19 https://www.kylheku.com/cgit/advent/tree/2021/19 Some people's solutions used some linear algebra libraries in ways I don't understand; one day I will revisit that.
- Snild 4y agoEach year does vary slightly in theme and focus, so it's possible you'll have more fun this time if you give it another chance. Or not. But remember that it's never too late to give up. :) My favorite so far is 2019, where several of the problems had you write and extend an emulator for the imaginary (and wacky) "IntCode" computer.
- bdowling 4y ago2019 was excellent. Each day, the puzzle would have you adding new features (new instructions, addressing modes, input/output handling) to the emulator. The early days were fairly simple, but things got progressively more complicated. On one day the puzzle input was code that played a game of Breakout. Your task was to implement an emulated joystick that would play perfectly. The solution was the final score. On another day the puzzle required several virtual machines running in parallel feeding the output of one into the input of the next to get the final answer. Reddit r/adventofcode is also fun. People post not only solutions in various languages, but visualizations of solutions (e.g., an animation of that game of Breakout). Sometimes people post fun things, like a solution to a puzzle in Apple II BASIC and a video of it running on an actual Apple II.
- Crespyl 4y agoOne of the things I really loved about the IntCode problems was best exhibited by that Breakout game. One way of solving the problem was to create a joystick, as you said, but if you had built an IntCode inspector/debugger, you could also dig into the game code itself (your puzzle input) and find out where the blocks were in memory, and how much each one was worth, and just sum it up directly. It reminded me of Wastl's other big puzzle collection (Synacore) which also had a big emphasis on implementing a VM to host further puzzles on top of.
- MereInterest 4y agoI like that solution by code-diving. I had initially rigged up a joystick for it, but programmed it to to play itself to completion.
- bugfix-66 4y agoA different kind of programming puzzle: https://BUGFIX-66.com https://BUGFIX-66.com The idea is that you read and understand a small piece of code (full of useful techniques) and make a small change to demonstrate understanding. Games that require you to write the code are limited to rehashing the same old tired algorithms... reverse a string and other sequence techniques, edit distance and dp variants, optimization by binary search and evaluation, etc., the standard leetcode stuff. Basically, useless wankery you will never use. The competitive programming standards. If you don't have to write it, just understand it, the game can cover some very interesting new algorithmic terrain. It becomes part book, part game. Like Hacker's Delight: The Game.
- californical 4y agoI like this idea! Sounds more relaxing like I could passively work on it while on the train, and also see code examples that I wouldn’t normally be exposed to in my day job. Seems like it might help me get better at code reviews too. Granted, I don’t like doing code reviews (mostly cus it’s usually pretty uninteresting code). But I do like puzzles! I’ll check it out :)
- birdfood 4y agoI felt similar last year. I was trying to do them in Zig and Rust, and it felt like most of the challenge was just writing custom data parsers for poorly formatted data which felt too much like my day job.
- masklinn 4y agoFwiw there’s a few recurring formats, the old hands have a bunch of helpers for that and other things. Sometimes there’s something completely bespoke but the most commons are space-separated lines of things, usually ints, commonly fixed-size.
- dolmen 4y agoFor 2022 day 5, the hard part was parsing the input. https://adventofcode.com/2022/day/5 https://adventofcode.com/2022/day/5
- macshome 4y agoSame feeling for me as well. At a certain point it just stopped being fun and felt like work.
- makeitdouble 4y ago> felt too much like my day job Agree. I think it helps to do it in a language you're not familiar with, or with some artificial limitation on how to solve it (no third party libraries for instance). It takes more time, but felt less like a grind for me.
- seba_dos1 4y agoLast year I have used Python without using any imports and, whenever I felt like it, tried to golf it as much as I could. Turned out easier than I expected, even without any libraries Python is pretty powerful for this kind of tasks: https://gitlab.com/dos1/AoC21 https://gitlab.com/dos1/AoC21 There were only like two or three days that felt frustrating, but mostly because of the problem being poorly specified.
- 4y ago
- julianeon 4y agoCan't wait.
- 4pkjai 4y agoI love Advent of Code. I learnt Rust while solving last year's puzzles.
- x86x87 4y agoOne of the best ways to test drive a new language. Love aoc for this. In the 350 (for now) stars club.
- axiom92 4y agoI'm ready with my codex key.
- markus_zhang 4y agoLast year I went through 8 of them. I wonder what's the theme of this year. Hopefully it's somewhat closer to CPU design (because reading Soul of the new machine)
- Jtsummers 4y agoNot CPU design, but does involve a simple VM, have you checked out 2019? About half (1/3rd?) of the challenges involve a VM for "intcode". First few challenges get it up and running, then concurrency is added, and then challenges are presented inside it.
- markus_zhang 4y agoThanks, I'll check it out. Definitely close to my definition of fun :D I also cannot tolerate hard problems so probably will stop around the same number.
- Jtsummers 4y agoIf you enjoy that, the same guy made Synacor Challenge: http://challenge.synacor.com http://challenge.synacor.com Similar basic problem as the intcode VM but less need to dive into concurrency.
- markus_zhang 4y agoThanks! This is really cool~ One of my dreams is to consume small pieces of challenges of some topic, one sightly more involved than the previous, then viola! At the end I get to learn say 50% of a CS course. Books are good but they don't force me to write code. I'm a bad learner :D
- drc500free 4y agoReally enjoyed that one. I do it in Excel, and moving things around between registers actually maps really well to a spreadsheet.
- plandis 4y agoI did this for the first time last year. It was fun! Really excited to do in again.
- aliqot 4y agoOnce more unto the breach, dear friends, once more
- b5n 4y agoElixir ended up being a great choice last year. I contemplated using ocaml, sbcl, or guile this go round but ultimately decided to see how far I can get with awk. I'm feeling confident I can get by with awk using getline as needed, we'll see how long I endure... Best of luck to everyone!
- tomberek 4y agoYes! I did two years in awk (https://github.com/tomberek/advent https://github.com/tomberek/advent) and loved the ability to dig in and truly grok the language. The performance wasn’t bad, but the multidimensional array support and ergonomics were…meh. I’m contemplating Elixir.
- deleted 4y ago[deleted]
- discmonkey 4y agoTime for my yearly tradition of making it to day 4 in Haskell and feeling very smart before completely giving up on the first hard problem that needs regular arrays :)
- jinwoo68 4y agoTry Ocaml instead :)
- cglong 4y agoOr F# for that .NET ecosystem goodness ;)
- MrJohz 4y agoI tried that last year, and got worn down by how often I'd Google how to do something and get an answer explaining how recursion works from first principles as opposed to just pointing at the deciding standard library function that did what I needed. I want to try again this year, do you have any advice for how to get going with Ocaml as someone who has programmed long enough to understand how recursion, linked lists, and all that jazz works, and just wants to figure out how to be productive in the language?
- kodwx 4y agoAs a reference, my solutions to advent of code in OCaml (without any external libraries) are here https://github.com/kodwx/advent-of-code https://github.com/kodwx/advent-of-code
- bmitc 4y agoI’d recommend using F# maybe. Easier cross-platform story and well documented in the F# guide and reference. Guide: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/ https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref... Reference: https://fsharp.github.io/fsharp-core-docs/ https://fsharp.github.io/fsharp-core-docs/ Also you can use F# notebooks with .NET Interactive and the Polyglot Notebooks Visual Studio Code extension, which is great for something like Advent of Code.
- hk1337 4y agoHave you been impish or admirable?
- brudgers 4y agoAdvent is not an event that resonates with me.
- deleted 4y ago[deleted]
- xavdid 4y agoAoC is one of my favorite events of the year! I find the puzzles generally approachable, but interesting enough to spend time on. I also like that there's a definitively right answer, which motivates me in an interesting way. I've developed a base class over the years that handles input parsing, so I can focus more on the solutions themselves. Additionally I've been solving for a number of years, but for the past 2 years, I've done a daily explanation of the solution. I use interesting parts of the Python stdlib and walk readers through common algorithms. I've found it _incredibly_ rewarding and plan on doing it again this year. You can see all of those solutions here: https://github.com/xavdid/advent-of-code/tree/main/solutions https://github.com/xavdid/advent-of-code/tree/main/solutions Please let me know if you enjoy reading these, I love hearing from folks!
- katelatte 4y agoThanks for creating this and helping others learn! Amazing effort :)
- xavdid 4y agoYou're very welcome! I hope you (and any other readers out there) have found them useful.
- xdavidliu 4y agowow, your username somewhat resembles mine!
- xavdid 4y agoHa, so it does. A small world. :)
- jabagawee 4y agoI just skimmed through your repo, and I loved the way that you used AoC as an opportunity to share many of the batteries that are included in the Python stdlib. In one particular case, I wanted to also share some more fun corners of the collections module / common algorithms and sent you a pull request.
- TheBrokenRail 4y agoI'm excited to try again this year! Last year, I only got 7 days done before getting distracted because of how crazy December is.
- macintux 4y agoDifferent style of challenge that launched this year (found it in another HN thread a few weeks ago): https://protohackers.com https://protohackers.com You're asked to write server code that meets the given protocol definition.
- hansvm 4y agoI was just telling all my computer-adjacent friends about this. Hype hype hype!!
- hiyer 4y agoLast year I completed it in Python, but I'm pretty familiar with the language. This year I want to try in a new language - mostly either zig or rust. Eager to see how far I can get!
- hubraumhugo 4y agoI wonder how helpful GPT-3 and Copilot will be for this :) Not necessarily to solve the whole puzzle but rather to give hints when I'm stuck with a particular task.
- fabianhjr 4y agoIf Microsoft updates the model daily then you could easily get a copy of someone elses solution by the next day.
- bbischof 4y agoHehe, I had the same question: https://news.ycombinator.com/item?id=33812666 https://news.ycombinator.com/item?id=33812666
- vyrotek 4y agoVery. https://twitter.com/t3dotgg/status/1598181897783619585 https://twitter.com/t3dotgg/status/1598181897783619585
- nikolay 4y agoLast year when I was doing AoC in Go, I was pleasantly surprised how good Copilot is and it felt like magic. Given most of the time I use Terraform, YAML, JSON, jq, and Bash these days, I can't really appreciate Copilot, but last year I did!
- dagw 4y agoI ended up turning off Copilot last year since it was literally giving me complete correct solutions with no effort on my part. Kind of took the fun out of it.
- nikolay 4y agoI can't say it gave me complete solutions, but it really guessed my intent most of the time and saved me typing time so that I could come close to the winners who predominantly use Python.
- nikolay 4y agoNo, I'm not doing it. At least, I'm not doing it in real time! What a time waster - my family hated me! Sorry, offline holidays and online programming contest don't mix well! Enjoy your life, solve the problems after the holidays!
- asicsp 4y agoIf you are interested in Linux CLI text processing exercises (beginner to intermediate level), I'm working on a TUI app: https://github.com/learnbyexample/TUI-apps/tree/main/CLI-Exercises https://github.com/learnbyexample/TUI-apps/tree/main/CLI-Exe...
- matsemann 4y agoI wonder how the persons on the leader board manages it? First person today solved part1 after 39 seoncds, and was done with part2 after 53 seconds! I felt I was quite fast in being done with part1 after 3 minutes and part2 in 4 minutes (rank ~1000). I even tried to skimread the explanation to be fast, have a script to download the input and run it etc., but still no match!
- Jtsummers 4y ago1. Have everything in place at the start (a script to grab the inputs helps). 2. Use a language that makes the edit/run cycle short. 3. Be very familiar with that language and how to process input in it. 4. Have solved many similar problems in the past so you can parse these problem statements quickly. 5. Have solved many similar problems in the past so you know exactly what code to write or use (if you have a utility library).
- pedrosorio 4y ago“Have solved many similar problems in the past so you can parse these problem statements quickly” This sounds like an advent of code specific thing. The problem itself is trivial, no need to have solved anything similar in the past, but the description is so verbose (because it’s a cute Santa-related story) that it becomes hard to parse the problem we’re trying to solve, quickly. I don’t think this is common in any other competitive programming environment.
- deleted 4y ago[deleted]
- matsemann 4y agoFeel I have to disagree on this one. Firstly, most programming competitions I've been to have this kind of problem description as well, just check Kattis problems for instance. But secondly, while the problems in the beginning are trivial, you still have a huge advantage if you can immediately start programming without having to think, or having to look up a function in the stdlib. (Spoilers:) I probably wasted a minute today thinking about the solution of making a list for elves, and creating a new element whenever I saw an empty line. While a pro probably immediately did a split on "\n\n", summed and was done.
- schemescape 4y agoIs there any way to play without logging in (for previous years, if necessary)? I couldn't find anything on the About page that clarifies this. Edit: I see anonymous users in the leaderboard, so it seems like it might be possible.
- Jtsummers 4y agoYou have to have a login (Google, Github, Reddit, Twitter) to get inputs, and part 2 is only unlocked after completing (correctly) part 1 for any given day. You don't have to share your identity with anyone but the host of the server.
- david2ndaccount 4y agoYou have to log in, but you don’t have to reveal your identity or username on the leaderboard.
- LegionMammal978 4y agoNo, there is no way to submit answers without logging in. The "anonymous" feature is just a setting to hide your username from the leaderboards.
- gnubison 4y agoOther comments haven’t pointed this out, but the key thing is that each account gets a different input (so it's a little harder to cheat).
- dolmen 4y agoIt's easy to cheat by applying someone else's code (ex: from reddit) to your own input.
- jiggawatts 4y agoEvery time I do the AoC puzzles I wish for two things: 1) The site should ask for the language used to solve the problem and then use this as semi-scientific data for comparing "time-to-solution" for various languages. The sheer volume of data and the relatively high difficulty of cheating on novel problems would make this data set interesting and maybe even useful. 2) I wish all the puzzles had a "hardcore" mode where a naive approach would take a million years of compute, or exabytes of memory. Have multi-gigabyte inputs[1] such that the time-to-solution isn't just how fast you can bang out some simple parsers and loops, but the runtime performance would materially affect your time score. [1] A method for this would be to use an input-file-generator that is small to download but can generate huge puzzle inputs.
- dolmen 4y agoTry codingame.com. You'll see those stats and others' solutions (well, not on all challenges).
- matsemann 4y agoPart2 is quite often what you wish for in 2), isn't it? At least for the later puzzles, part1 is often something that can be solved naively, while part2 needs some cleverness to not blow up.
- deathanatos 4y agoYeah, usually part 2 is. Bear in mind that tonight's puzzle is a warmup, it's day 1 after all! I do find there's usually one or two spots that you can eek by with threads and throwing compute power at the problem. But those are rare — usually you have to actually solve it.
- charcircuit 4y agoIn previous years there have always been several I can just use a massive swapfile to get it
- xigoi 4y ago> site should ask for the language used to solve the problem and then use this as semi-scientific data for comparing "time-to-solution" for various languages. I think this would just show you the average time zone of the language's users.
- BooneJS 4y agoI’ve used AoC to dabble in new languages. This time I’m going to learn emacs instead. Vi/vim for over 20 years…
- deleted 4y ago[deleted]
- w-m 4y agoIf you want to join a small just-for-fun leaderboard to keep you motivated to go through to the last puzzle, feel free to join 194284-90c48b41 I've created this leaderboard last year and announced it here. It has a few people I know personally, and a few people from HN I've never met. There's no community Discord or anything like that. The only form of communication are the stars appearing after other people's names after a while :)
- marshmallowmad 4y agoFirst day was a pretty fun start. Just heard about this for the first time this year and going to give it a go. Tangential question - why does the HN crowd hate these types of questions in interviews but apparently likes to do them on their own time? Different folks answering to different posts? Honestly curious.
- saagarjha 4y agoIt's optional in this context.
- deathanatos 4y agoWhy would it be optional in an interview? You want a job, I want to know that you've seen software development before. (Now for context, the interview questions I typically would recommend are a order of magnitude easier than AoC's typical bar, in the language of the candidate's choice, ideally on a real computer and not a whiteboard. Tonight's question though (a warmup) wouldn't be a bad one. It's straight-forward, no trickery, nothing clever, and directly applicable to real-world coding. And it would screen >50% of candidates that I'd give it to.)
- sureglymop 4y agoPersonally i just think it's not a good way to assess. Such challenges are mostly about coming up with "creative" solutions. I think that pressure can be good for creativity but it can also be it's death. However, motivation is important for creativity. Competing online with other like minded people is a good motivation whereas a job is something you need literally in order to survive. It's not really comparable imo.
- deathanatos 4y ago> Such challenges are mostly about coming up with "creative" solutions. No, or you're strawmanning the type of interview that is being suggested here. No, the challenge is about solving the problem; it doesn't take "creativity" to find the maximum in a list of integers, and the problems a SWE is going to encounter in the real world far dwarf such a question in terms of difficulty or "creativity" required to solve. Some of the rougher AoC problems are harder, yes a bit more so. But a.) I qualified that that's not in context here in the original comment and b.) even there, it often isn't creativity that's required, it is knowing your basic principles, e.g., what data structures exist and when to apply them. But HN has an anathema when it comes to this sort of stuff; heaven forbid that SWE requires skills. > I think that pressure can be good for creativity but it can also be it's death. However, motivation is important for creativity. Competing online with other like minded people is a good motivation whereas a job is something you need literally in order to survive. It's not really comparable imo. This is mostly non sequitur. There's no eliminating stress completely from an interview, but depending on what tech I have handy, allowing the candidate a full REPL, access to reference material, coding in an IDE and language of their choice are all there to reduce stress and let the interview focus on what hopefully the candidate is good at. I'm not attempting to compare competing online with an interview: you're not competing online in one of my interviews. The sort of problems, however, as an example of what might be asked in a coding question is the scope of what is being compared here. The point is: a. they're not the infamous sewer lid question b. they don't require "one clever insight" to solve and c. they in many ways mirror real-world issues. (E.g., parsing an input, taking an english description and turning it into relatively simple code.)
- reducesuffering 4y agoPSA for anyone that doesn't like the verbosity: the bolded white words are the key info. Here's how today's #1 did it (day 1 solution SPOILER): https://youtu.be/Vl1w7kWRtDg?t=144 https://youtu.be/Vl1w7kWRtDg?t=144
- mikewarot 4y agoI'm doing it in Lazarus/Free Pascal again. https://github.com/mikewarot/Advent_of_Code_in_Pascal https://github.com/mikewarot/Advent_of_Code_in_Pascal
- deleted 4y ago[deleted]
- lkuty 4y agoYou reminded me of Pascal. I used it at school in 1994 (on an IBM RS/6000 I think). I was planning to do the AoC in Shen (I already know Scheme) but you make me want to do it also in Pascal. Thanks for sharing your solutions. The presence of files with the "lpi" and "lps" extensions means you are using an IDE ? Moreover, I thought the extension for Pascal source code was "pas" but I see "lpr". Why ?
- mikewarot 4y agoLazarus is the GUI IDE based on Free Pascal, and for some reason I think they use LPR to mean Lazarus PRogram. I could very well be wrong.
- bmitc 4y agoI'm using Elixir and a Liveview notebook this year to go through it. Using Liveview notebooks is so nice, as you can even add and run `ExUnit` tests within one. So, it's just a single document in which to work with syntax highlighting, formatting, modules, tests, etc. I may also do it in F# and .NET Interactive notebooks using the Polyglot Notebooks Visual Studio Code extension, but I suspect the solutions will look very similar.
- bmitc 4y agoCorrection: I meant a Livebook notebook instead of "Liveview notebook", the latter being a framework for Elixir frontend apps.
- cranium 4y agoI really like how the Advent of Code is structured. Not only it makes you think about how to solve the problem, it pushes you to architecture your code defensively so when you get the new requirements in part 2, you have the least amount of code to change. I remember being bitten in a problem involving a keypad: I didn't think the keypad shape could change!
- charcircuit 4y agoI personally hate it. I wish they could just give a clear specification of what they want instead of putting it in the format of a story where some things are vague.
- Smaug123 4y agoOne person's "architecture your code defensively" is another person's "make a dumb solution so that you don't waste effort being smart".
- peheje 4y agoTo me, often the "dumb" solution is the modular one, because I can't design the entire solution at once, but I can parse this string into this format, and then I can find out whether this sequence is contained in the other, and then I can map some chars to a number, and then ah..! the solution is just calling these 3 functions in the right order. Part 2 is just swapping one of the functions out with the other, great. Now this is simplified I know, but I'm not convinced in your proposed duality.
- markeibes 4y agoYou can also try https://advent-of-pure-code.vercel.app/ https://advent-of-pure-code.vercel.app/ as an alternative
- lynguist 4y agoOh no, I forgot about this! I’m in the holidays and specifically didn’t take my laptop with me!
- wodenokoto 4y agoHow much external help do you guys seek out for these puzzles? Last year I solved two puzzles by looking up the answer on reddit, and other than that I tried to solve them as is. But I feel like it is sometimes a bit like solving a puzzle is a bit like reinventing parts of math and computer science if you didn't happen to have learned those from school or a book.
- dolmen 4y agoExactly. This a very good set of exercises for training on algorithms. Use platforms such as codingame.com for more targetted training, or if you need motivation.
- anxiously 4y agoLooks like fun. Too bad you can't sign up anonymously or simply with a username and password. What a shame.
- tomjen3 4y agoAgreed. I was looking forward to it, because puzzles, but yeah, no. I am not an enterprise, don't care to lock me down to a specific service.
- oweiler 4y agoWanted to use Rust this year but bc of time constraints felt back to Kotlin script, which is perfect for these kinds of tasks.
- Drblessing 4y agoLets go!
- shaftoe444 4y agoFor the first time in years I'm going to use my day to day language and not try anything fancy!