Advent of Code 2021
adventofcode.com
adventofcode.com
Last year I was earnestly trying to compete on the global leaderboard, and scored points a few times, ending up 103rd overall (slightly frustrating as the displayed leaderboard only goes down to 100th place!), but it's too stressful for me to want to do that again, and in my timezone it requires getting awake in time for the puzzles to be released at 5am.
This year I've been building a homebrew 16-bit CPU from 74xx logic, and have written an operating system and development environment for it, and I plan to do as much as possible of Advent of Code 2021 on my homemade computer.
There are 2 big hurdles to this. The first is that my computer is very slow. It takes over a minute to compile a typical program, which makes for a very long edit-compile-test cycle, and I don't have any hardware multiplication etc., so even integer arithmetic can be quite expensive.
The other hurdle is that it only has 64K words of memory, and IIRC some Advent of Code problems in the past have required keeping track of state for dozens of thousands of separate things. In those cases I'd either fail, or come up with a way to use the disk for extra storage. I look forward to trying, regardless.
As it happens, just this morning I did kind of a "dry run" on problem 1 from 2016 on my homemade computer, and recorded my attempt, which you can watch if you want: https://www.youtube.com/watch?v=UOizI9qi6FU
But implementing Forth on my CPU, and getting proficient at using it, is definitely something I'd like to do at some point!
It's something that many programming language tutorials miss: exploring the possibility space and teaching you the language's expressive power
Thinking Forth: http://thinking-forth.sourceforge.net/
In combination, very effective introduction to programming in Forth including how to go about combining those building blocks.
Try reading Jonesforth, a literate Forth implementation in one x86 assembly file and one Forth file. You can read it top to bottom and it will explain how everything works step-by-step.
https://rwmj.wordpress.com/2010/08/07/jonesforth-git-reposit...
Github mirror: https://github.com/nornagon/jonesforth
This is the github repo that contains everything: https://github.com/jes/scamp-cpu/ - some of the stuff under "doc/" might be what you're after (but some of it is just incoherent ramblings).
I have some blog posts here: https://incoherency.co.uk/blog/tags/cpu.html
And there is a video here, but it's not really very informative: https://www.youtube.com/watch?v=4sBB0iD6XvI
It's slightly more complicated than just having 1 register to drive the upper bits of the address, because if you just blindly switch on some of the upper bits of the address then suddenly all of your instructions go missing and the CPU starts executing whatever arbitrary bytes happen to be in memory. So you'd want some way to switch out just the parts you want to store data in, while leaving all your code still mapped in.
I have an RC2014 with the bank-switching memory expansion. The RC2014 handles it by splitting memory into 4 (I think?) "pages" of 16K each, and allowing you to select which bank backs each page separately.
I also recall some systems where it works just as described, but you had to be incredibly careful about bank switching and IIRC there was a dedicated instruction to write the bank register and program counter register at the same clock cycle.
>I have a puzzle idea! Can I send it to you?
>Please don't. Because of legal issues like copyright and attribution, I don't accept puzzle ideas, and I won't even read your email if it looks like one just in case I use parts of it by accident.
It's sad that we live in a world where code snippets sent by others can result in legal issues down the line.
If they open it and accidentally make a movie/tv-show that's too similar, they're liable to get sued. But if they can prove that all unsolicited mail is disposed without opening, they're golden.
It's very easy to recommend to it anyone who does any amount of programming at any level, from complete beginners to very experienced.
Other people in this thread are talking about learning new languages and I found that a bit distracting. I think I'd rather focus on the puzzles themselves and there's also something very satisfying about writing a clean and concise solution in a few lines which you can't always do when you're picking up a new language. I like using Python for it because I can just translate what I'm thinking to a solution without worrying about the language itself. Also, even if I didn't mind doing it in a new language, I don't think that AoC gives you large enough problems that can really explore a new language and all of its features. And you can always mix the languages if there's a language that's really suitable for a given problem. You don't have to stick to the same language for all problems.
I really enjoyed last year's, I'm looking forward to this one.
e.g. 2020 Day 1:
https://old.reddit.com/r/adventofcode/comments/k4e4lm/2020_d...
Unfortunately my implementation was incredibly slow (probably because of the linked lists) and I only made it about halfway through.
I think it started in 2015.
On the AoC website you need to provide solutions for each day in a given year to see the next day’s problem, so you can’t instantly see all the problems from a given year unless you’ve previously completed them.
You may be able to find the problems elsewhere on the net.
Not everyday is about intcodes, but day 2, 5 and 7 are the first 3 days with intcodes and they built on top of eachother.
I suspect it's much more a time gulf than a skill gulf.
I love AoC as well and don't so much burn out but find that after a week of coding for fun in the evening a mountain of real world responsibilities start piling up, especially around the holiday season.
When I was in undergrad I had virtually no family responsibilities during December and a large amount of free time when classes ended, so it would have been easy to spend hours a day on AoC. Many younger, single professionals are likely in the same situation.
I think for most adults with family responsibilities and full time jobs (and likely a range of side projects that also need attention) that first week of December is a rare lull, and a great time to solve a bunch of fun code problems. After that more and more other things take focus as the holidays approach.
Don't you need a way to generate more inputs in addition to the one you have?
Basically every puzzle comes with unit tests that just need to be translated into code.
It's at least good to hear that Go is a competetive option!
if you do it deliberately it's a good way to learn a new language.
There is also Rosalind for more data oriented challenges [1].
I haven't gotten too far, but the initial problems don't seem too hard in higher level languages. They are very good problems to get better at IO, string manipulation, and data wrangling in your language of choice though.
Same.
> I haven't gotten too far, but the initial problems don't seem too hard in higher level languages.
True. But the info boxes in the top are interesting and informative, those make it worth it to keep going.
> They are very good problems to get better at IO, string manipulation, and data wrangling in your language of choice though.
For me, it's also a way to peek into BioJulia and get some familiarity with it. (I don't mind "cheating" this way since this was my primary goal with the site anyway.) So far I'm pretty impressed by how fast it is!
Last year I did typescript and tried to really focus in on the type system.
While I think python is a really great language for advent of code, I'm not sure I'd recommend going for an OOP-heavy style. Although that might just be a matter of personal taste - I think OOP is a poor strategy for most problems.
The reason LFE didn't do it for me was that Elixir is relatively painless syntax-wise, and has really nice high-level libraries like Phoenix and Ecto that simplify a lot of work. If I don't need the BEAM, than I'd rather have a more strictly functional language like Clojure, or something more low-level like Common Lisp. LFE doesn't occupy a niche in my personal ecosystem. That being said, I'd definitely give it another try sometime, and I'd recommend it to anyone else who wants to feel the power of the BEAM.
I first heard of people doing this for codejam, and it works just as well for AoC
My 2c from the experience,
* I hated Go for this style of programming, but I could see it being good for some production-ready code
* Rust should be renamed to Rustcargo. Even for the most basic of tasks it seems like these two are welded together.
* I still really like Nim as a replacement for Python in my toolbox
I much prefer RustCargo to C++BringYourOwnShittyBuildSystem! Cargo definitely one of the bright spots in Rust imho.
For something like Advent of Code, though, I'd avoid it. It's just me and it's not for long; there's no need for me to be explicit about how I'm thinking about the problem.
The problems are designed to be solved in Python with less than 100 lines of code, by taking advantage of Python's extensive library of data structures and algorithms.
There's numerous problems from board or combat game simulations, to mazes and the intcode computers that lend themselves to be approached in OOP style. The context OP is coming from is data science scripting, it's fine to start with small examples.
I don't go for being the fastest or anything, I just want to do everything in a way that I like. Last year I did everything on the same day it got out; I plan to do the same this one, unless there is a particularly bullshitty problem that puts me off.
That said, I don't think it's great for really getting in depth understanding of any language in particular - you'll only use a limited subset of language features for these problems.
Make an API client, a GUI or game if you want to use OO in Python canonically.
Not sure if doing again, but could be useful resource
He got onto the leaderboard for fastest solutions with APL, too.
Implementing Intcode in Nim for 2019 was really pretty fun
I've been trying to think I've something, else fun to do or maybe use a language I've been itching to try, like Ada, but based on the first question it seems it'd just be boring to so in a language like that. I can think of a ton of other gimmicky solutions, but none that are very fun.
Day 1 Day 25 Ratio
2020 163763 13016 7.95%
2019 103187 3399 3.29%
2018 71480 3192 4.47%
2017 48543 5577 11.49%
2016 19299 2772 14.36%
2015 55970 4171 7.45%
Based on https://adventofcode.com/2020/stats, https://adventofcode.com/2019/stats, https://adventofcode.com/2018/stats, https://adventofcode.com/2017/stats, https://adventofcode.com/2016/stats and https://adventofcode.com/2015/stats.this year I guess I should probably have mathematica installed
Love it and excited for 2021
I got frustrated half way through because most of my time was spent fighting parsing bugs, since AOC tends to give you the data in very inconvenient formats.
Do you have a repo somewhere with the lisp code?
It makes working with the F# REPl very nice. I also had a good experience with F# type providers on consuming external input like AoC's.
This year I'm going to be hosting a series of workshops to discuss solutions in Python.
Participants will come to the workshop having already implemented the problems we will be discussing. The goal will be learning about more intermediate and advanced features, testing, OO vs functional solutions, utilizing editors efficiently, getting feedback, data structures and runtime, and improving your coding ability.
You'll want to know how to open and read a file, parse input (generally line by line, splitting each line on spaces), get familiar with data structures such as the dictionary/hash map and how to use the OCaml version. Not that you'll be competing for the leaderboard; this is more about getting familiar with the typical things for solving each problem.
Leaderboard points are only assigned if you're in the top 100 for either parts which you should ignore if this is your first time since it's not the point!
In the past, I've given up on AoC after a couple weeks due to time and conflicting priorities. With two whole weeks of free time that coincides with the hardest puzzles, I guess I know what I'm doing in December.
I've (somewhat) participated the last few years, more as a way to learn new languages, I've never actually made it through all the puzzles yet. I got fairly close with Rust last year, before getting burned out by the end. I'm currently debating either doing it with Nim or Ruby, of which I've never written a single line of in my life, but I'm curious to try out.
Last year I'd asked for some getting started advice here: https://www.reddit.com/r/nim/comments/k22h74/advent_of_nim_2...
I have become so affectionate of both (Nim and Advent of Code), that I always look forward to this moment of the year!
Last year I used it to test my notebook library nimib [1] (and it was first, and currently only, year that I completed the calendar). This year a nice challenge could be to try and use a different library from Nim ecosystem each day (always wanted to use Nico for this, Manim looks it could give nice results, …).
[0]: https://news.ycombinator.com/item?id=18045259
[1]: https://pietroppeter.github.io/adventofnim/2020/day11.html
I'm vacillating between doing it in C# and Javascript/Typescript this year. C# has gotten more attractive lately as there are improvement that makes it less ceremonious for short programs, like toplevel statements and global imports, and also fun optimizations for ricers. If I do it in JS/TS I would do it in a web environment, and try to do it with a nice web GUI.
His 2018 AOC stream https://www.twitch.tv/collections/YDM6eKu6bhV1Nw
I look forward to it!
How hard would it be for someone to finish the entire thing? I'm planning to use this as an opportunity to learn Python. I have some programming experience in Java, C, and JS but not that much.
Overall it is absolutely worth attempting, you'll learn something guaranteed, about algorithms, about the language(s) you chose and about yourself (resilience and determination).
It often takes me 15 or 20 minutes to read and understand the problem description. But it sounds like you frequently had solutions written within that time!
A couple of years ago I used Advent of Code to learn Rust. This year I’m going to use it to learn Zig.
https://www.forrestthewoods.com/blog/learning-rust-via-adven... https://www.forrestthewoods.com/blog/solving-advent-of-code-...
To be clear, I don’t compete for the leaderboard or code golf. But I do try to write elegant code that’s performant.
AoC is a great way to learn a new language. I try to solve the puzzles entirely on my own. Then I check the Reddit solutions thread and Ctrl-F my language. It’s a great way to learn new tricks, libraries, or just idiomatic language style.
And using Rust for AoC turned me into a certified fan. Rust iterators are really great compared to C++. They’re like C# linq but better. The itertools crate is super helpful.