I don't know about you, but I struggled to bend C to my will yesterday. Had to do it in Python to stay on top, but now that I've done it in Python...
For further actions, you may consider blocking this person and/or reporting abuse
I knew Rust would shine for the machine simulations. Let's hope for more of these.
Full code
Python!
Rust! I am doing WAY too much object copying. I think I could get the same results by passing vector of references around. But, wanted to not think too much :)
hello! Sorry did not post yesterday as was visiting my mum in hospital, but completed day 7 this morning, which I have to say was a bit messy!
Day 8 on the other hand seems a lot of fun and I'm remembering more Haskel (and cateory theory) each new day. It's been a while :-) Anywhy, below is today's soloution(s). I did give into using Parser combinators as it just seemed simplier, but other than that it is all fairly standard.
as soon as i saw this, i remembered the IntCode shenanigans from last year...can't wait til we're forking off 4 copies of this VM to run in parallel or talk to each other or whatever :)
ts solution was pretty compact here, although I got tripped up by the sneaky blank line at the end of the input! I've been doing this for a few years and we're 8 days in, you'd think I'd remember that by now haha.
COBOL. I'm struggling... nothing yesterday and only part 1 today
Functional Programming approach with relatively fast Rust code
Ruby, part 1:
Ruby, part 2:
My solution in C#
Tried to make it look decent with the Operation enum and an Instruction class:
Here's a javascript solution. Toggle
part2
to false or true depending on what part you're on.This was much more enjoyable after the utter faff that was day 7
More javascript, less regex. I get the feeling that I'm going to have to give up on my regex quest.
Here's my solution for part 2 in Elixir. It shares most of its code with part 1, so I don't think it's all that interesting to share both.
Another OOP solution in Ruby.
Well this felt a lot easier than yesterday... Looking forward to see whether we're going to be expanding on this one in the coming days...
BootSequence
Part1
Part 2
Python
My solution for day 08, where I have tried to make it easy to extend. Just in case we have to continue building on this another day 😬 (getting some intcode flashbacks from 2019...)
Rust solution.
I spent longer than I care to admit trying to figure out the best way to access/use the data from the initial input in a mutable way: I started with returning the Program from the input parser, but nothing could be mutable that way; I tried boxes, I tried Rc, (both of which I haven't really played around with before); finally settled on making them Clone-able and just duplicating it for the run.
There's some control flow stuff in here that I'm sure there are better ways of solving (if you know or have a suggestion, please drop it in!).
Also gave me nightmares of last year's opcode parser... 😱
As always, on Github.
I think the insight you need is to separate the mutable from the immutable state. The program is immutable (except for the modifications in part 2) but the machine state is mutable. The instructions are immutable but the record of visiting them is mutable. Cloning the whole program and changing one instruction is the right approach however. Good work!
I solved Part 2 in python but uh... in a slightly unconventional way. I re-wrote the CPU so that it used Redis for memory instead of variables, wrote functions so it could operate one cycle at a time every time the script was run, built it into a Docker image, and pushed it to a registry, and then wrote an Airflow DAG to orchestrate running of the CPU inside a kubernetes cluster.
And then had it brute-force the solution by running it one cycle per Kubernetes Pod, deployed by Airflow, until it found the answer and sent it to me via Slack.
Blog: dev.to/meseta/advent-of-code-day-0...
Omg you’re a hero. This is so very impressive
Writing today's solution went pretty fast. But oh man, it takes longer and longer to write these step-by-step tutorials. I'll have to see whether Life™ allows me to continue this until Xmas:
[Advent of Code 2020] Day 8 Step-by-Step Tutorial (TypeScript)
Kai ・ Dec 8 ・ 9 min read
Had a much better time today. I'm very happy with how this came out.
My Javascript walkthrough: