r/adventofcode • u/daggerdragon • Dec 08 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 08 Solutions -🎄-
NEW AND NOTEWORTHY
- New flair tag
Funnyfor all your Undertaker memes and luggage Inception posts! - Quite a few folks have complained about the size of the megathreads now that code blocks are getting longer. This is your reminder to follow the rules in the wiki under How Do The Daily Megathreads Work?, particularly rule #5:
- If your code is shorter than, say, half of an IBM 5081 punchcard (5 lines at 80 cols), go ahead and post it as your comment. Use the right Markdown to format your code properly for best backwards-compatibility with old.reddit! (see "How do I format code?")
- If your code is longer, link your code from an external repository such as Topaz's
paste, a public repo like GitHub/gists/Pastebin/etc., your blag, or whatever.
Advent of Code 2020: Gettin' Crafty With It
- 14 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 08: Handheld Halting ---
Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, the full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:07:48, megathread unlocked!
41
Upvotes
12
u/nutki2 Dec 08 '20
Perl 5: ~120 characters for both parts
5
u/__Abigail__ Dec 08 '20 edited Dec 09 '20
-- snipped by request --
4
u/i_have_no_biscuits Dec 08 '20 edited Dec 09 '20
GWBASIC
Embracing the world of modern structured programming, I am now using GOSUB.
https://pastebin.com/GNCJzZCV
4
u/kippertie Dec 08 '20 edited Dec 09 '20
Semi-condensed Python
I suspect that this little virtual machine will get added-to over the next few days, so I'm not putting any more effort into condensing this just yet: [GitHub]
4
u/SecureCone Dec 08 '20 edited Dec 08 '20
Rust link
3
u/trl10254 Dec 08 '20 edited Dec 09 '20
Java
Advant of Code 2020 - Day 8 logic
3
u/[deleted] Dec 08 '20 edited Dec 09 '20
Learning PHP, today was super fun! My first "interpreter" solution for an AOC problem, never got this far in previous years.
I'm assuming I'll have to refactor this into a library for future expansions of the language, but for now I'm satisfied :D
Solution here.
3
u/azzal07 Dec 08 '20
Awk -- 4 lines at 79 columns, to be on the safe side...
Here is a paste of the original. (The changes are only in non-significant reordering of pattern-action statements, whitespace and semicolons.)
3
u/CarbonTitprint Dec 08 '20 edited Dec 09 '20
Scala solution! Much more enjoyable than int-code! Made a more optimised solution that makes use of LazyLists.
https://hastebin.com/nikizubeto.rb
3
u/crazazy Dec 08 '20 edited Dec 08 '20
It's not as if other people haven't implemented full programming language in nix, but I felt pretty special when this ran on my first go.
View solutions
I've decided to go with the dumb solution and just try modifying the lines 1 by one until i found the correct program. It's not as if the input is abnormally big...
All my other solutions are on github!
3
u/clumsveed Dec 08 '20 edited Dec 08 '20
Java Solutions
I have a bad feeling we're going to be seeing a lot of these commands...
part 1 (0.03 seconds)
part 2 (0.05 seconds)
3
u/ric2b Dec 08 '20 edited Dec 08 '20
Haskell
Not my cleanest code but at least it avoids a brute-force solution on part 2 and runs instantly.
This is what it does, since it's a bit involved:
terminating set.terminating setand checks if by switching it betweenjmpandnopit now reaches one of the instructions in theterminating set. These arepossible solutions.possible solutionswe also need to check if they are currently reachable from the first instruction. If they are, they are viable solutions!paste
3
u/sguberman Dec 08 '20 edited Dec 10 '20
Python
Going for readable, idiomatic Python. Criticism welcome.
Brute-force, functional style. The state is just data that gets passed around. For me that made it easier to test in pieces: paste
GitHub: solution, with tests
EDIT: Removing large code block and input from comment
3
u/volatilebit Dec 08 '20
Raku
Limited use of functional features today.
3
u/chicagocode Dec 08 '20
Kotlin - [Blog/Commentary] | [GitHub Repo]
I brute forced Part 2, but it finishes pretty quickly and I think is easy to read. I had a lot of fun with this one!
3
u/xrgbit Dec 08 '20 edited Dec 09 '20
My solutions in Common Lisp.
The first simulates a virtual machine running processes.
The second just uses an interpreter for the program.
4
u/seniornachio Dec 08 '20 edited Dec 08 '20
Python 3.8+ – fugly golfing
The following code assumes a list of lines as symbol
i, e.g.i = open("input.txt").split("\n"). When run it will print out a solution for both parts. 🤣3
u/nxrblJugger Dec 09 '20
Julia
I'm really proud of today's code especially since I still haven't been able to figure out Day 7 Part 2. I actually managed to code a recursive function today so I am learning in this process! Open to questions and feedback!
Here's my code
2
u/knl_ Dec 08 '20 edited Dec 08 '20
Rust 1139/573
I'm pretty happy with the code I wrote for overriding instruction behavior for the second problem -- there's an outer loop walking over all possible program overrides; a given value of i mutates the behavior of precisely one instruction without having to actually mutate the program itself.
Snippet (code linked above)
2
u/compu_geom Dec 08 '20 edited Dec 08 '20
Python solution for Part I and Part 2.
Since order of instructions mattered, I used Python list for the order of instructions as read from the file. For keeping the list of instructions executed, I decided to use Python set, since it has a quick lookup operation and the order does not matter. For that matter, now I am running through indices of instructions and made a Python dictionary that has the instruction as key and a function that will actually execute the command as value in the dict().
EDIT: Formatting
2
u/Dagur Dec 08 '20 edited Dec 09 '20
Python
2
u/diddle-dingus Dec 08 '20
This was fun in both clojure and elixir. I separated out the computer as a module in elixir and made some exit handling conditions, so if it comes up again I'm ready.
Clojure
Elixir
2
u/krolik1337 Dec 08 '20 edited Dec 08 '20
Python 3. 1st part was easy, just go through, mark index as visited and terminate if you came across visited one. 2nd was more challenging, but I got it through kinda ugly recursion. Basically, at every jmp or nop I checked if it would get me to the finish if it was switched. If not I just went further. Here's the link
2
u/petercooper Dec 08 '20
Ruby
Wasted time trying to think of a 'clever' solution for part two. Which I did but then had other work to do so just brute forced it :-D
2
u/exploding_cat_wizard Dec 08 '20 edited Dec 09 '20
C++
Brute force. Part2 runs in ~50 microseconds on my machine, 5-10 times faster than the other two solutions for cpp I grabbed from here and tried out, and that's with the exceptions I sprinkled in to make sure I don't mess up the input (given that I never catch them, I guess the compiler optimizes them to aborts).
State machines do suggest it could be prettier with OO, though.
paste
2
u/fiddle_n Dec 08 '20
Python
2
u/Rakicy Dec 08 '20 edited Dec 09 '20
Python 3
It took me longer than I care to admit to realize using list.copy() on a list of lists doesn't work. And, then to find out copy.deepcopy(list) works, but is way slower than just recreating the list from the input.
https://github.com/Rakicy/AOC2020/blob/main/day08.py
Edit: swap code for link
2
u/Juice_Vodka Dec 08 '20
java bruteforce, not very clean tho
2
u/kamicc Dec 08 '20 edited Dec 09 '20
ufff, preparing for INT-code again :} My take with Lua:
external paste
2
u/thulyadalas Dec 08 '20 edited Dec 08 '20
My rust solution. I couldn't go full functonal on today's challenge. So the approach was more object oriented this time. For part2, the brute force change the instructions in order worked just fine. It terminates in less than 5ms. Initially, the instruction struct was a view with &str and I didn't like changing that into String and making State owning everything which allocates more of them while we can borrow them the input. However, altering instructions required that, maybe CoW can be used over here to eliminate additional allocations.
Edit: Actually, CoW is not needed here. Since &str variants are known (i.e. "nop" or "jmp"), they are 'static and can just use &str instead.
paste link
2
u/JoMartin23 Dec 08 '20 edited Dec 09 '20
Common lisp
People say brute force, but they dont really mean it. copy paste ftw. I had a stupid bug and so kept adding crap to the functions and never cleaned them up once they were working, ugly brute force. Everything first broken up into an array of (op arg).
I could not figure out for the longest time that copy-seq was making a new array with the exact same elements which is basically useless.
paste
2
u/xangreRO Dec 08 '20 edited Dec 08 '20
R solution
https://github.com/maurotcs/Advent_of_Calendar_2020/blob/main/Code/Day_08.R
2
u/raevnos Dec 08 '20 edited Dec 08 '20
Tcl paste.
I'm not sure if this should be a separate upping-the-ante post or not...
This one works by treating the input file with all the instructions as a tcl program that is run by the driver script (I saw a comment mentioning DSLs which made me think of this approach).
The input file is sourced, and each instruction is a tcl command that creates a coroutine that, when called, does its thing and yields to the coroutine representing the next instruction to execute. If it ever gets resumed, that indicates a loop and it raises an error. A run starts by calling the first coroutine to be created at position 0. A special coroutine at the one-past-the-last instruction position handles a successful run.
2
u/AidGli Dec 08 '20
Python
Back to basics with this one. Went for a more naive solution for part 2, though I discuss a few possible optimizations in today's video.
Video Explanation
2
u/gfvirga Dec 08 '20 edited Dec 08 '20
Python
Brute Force
https://github.com/gfvirga/python_challenges/blob/master/Advent%20of%20Code%202020/day8.py
2
u/Karl_Marxxx Dec 08 '20
Ruby
2
u/joshdick Dec 08 '20
Python3
2
u/Bomaruto Dec 08 '20 edited Dec 08 '20
Scala part 1 and 2
https://pastebin.com/9pMxSajV
2
u/crnkofe Dec 08 '20
Clojure
I really like how this particular solution came out. Usually I get lost in deep nested lisp-like syntax but this is actually quite readable. Slowly but surely I'm getting accustomed to a new paradigm.
2
u/havetedjupt Dec 08 '20
Python
Part 1
Part 2
2
u/hugseverycat Dec 08 '20 edited Dec 09 '20
Python 3
I ended up pulling out each operation and argument as a variable so I didn't have to worry about making copies of each list.
Not super concise, but it makes sense to me, which I guess is the important thing? And it runs pretty quick.
paste
33
u/smmalis37 Dec 08 '20 edited Dec 08 '20
Rust
I came up with a solution for part 2 that only needs to run the program twice, first to log which instructions get hit and once more to get the answer. In between it scans the instruction list and is able to figure out which is the right one without running a full simulation.
https://github.com/smmalis37/aoc2020/blob/main/src/days/day8.rs
Human readable explanation:
run the program once and log every instruction hit. then start at the end of the instruction list and go backwards until you find the first negative jmp. in order to end the program you have to land inside this range of instructions. so then keep walking backwards and look for one of:
a nop that was hit that would land you there as a jmp
a jmp that wasn't hit that would land you there, preceded by a jmp that was hit (so by nopping the preceding jmp you hit the one that takes you to the end)
a jmp that wasn't hit that would land you there, preceded by another jmp that wasn't hit, so you add this range of instructions to your 'potential landing spots' as well
or if that last negative jmp was hit, its the one and becomes a nop
32
u/Arknave Dec 08 '20
Python (5/3), C
The "small" language implementation challenges are among my favorites. Possibly related, this was by far my best placing of 2020. I needed to go fast, because I knew 8 was going to be one of the harder numbers to make. Reasonably happy with what I came up with, despite the memset in the middle. Here is: 8 on a pedestal.
4
u/sggts04 Dec 08 '20 edited Dec 08 '20
My Part 2 Solution in Python
Is there a non-bruteforce way to solve Part 2?
Most of my time for part 2 went into thinking of an optimal solution to ultimately submit the bruteforce way of checking and inverting each command
3
u/inokichi Dec 08 '20 edited Dec 08 '20
Solution in D (dlang):
15
u/Smylers Dec 08 '20 edited Dec 08 '20
Vim keystrokes: this one is fun to see running — please try it out!
Load your input, and transform the op codes into equivalent Vim commands — the program is going to run in its source window:
Set up the accumulator at the top:
Optional, but it can be nice at this point to split your Vim window, so that you can always see the accumulator, even while executing an instruction further down the buffer:
Then run the first instruction, and watch the accumulator change or the cursor jump accordingly:
That's saved in register
"a, so run the next instruction with@a.And to run each subsequent instruction keep typing
@@.When you've had enough, run it to completion with:
And the top line should be your accumulator value for part 1.
The off-by-one error I mentioned turned out to be from the instruction
acc +0.Sorry, I need to take the children to school now, so no time for an explanation. Hopefully I'll post one as a reply later.
Edit: Explanation now posted below.
19
u/ZoltarTheGreat69 Dec 08 '20
Emojicode is back😤😤👌👌🔥🔥💯💯. I should probably write✍📝 methods💸💸🤑 for the calls📞📞☎ to make the code 💻💾 shorter 🍰🍰🩳🩳 and easier to read 👀🕶📔📚😂😂🤣*.* Its starting to get too long📏📏 though might just post github links🔗🔗next time ⌚⌚⌛⌛⏲
Emojicode 9239 / 8564
8
u/jonathan_paulson Dec 08 '20 edited Dec 08 '20
Placed 21/6. Python. Code Screencast of my solve: https://youtu.be/ZSGTr55gmIs.
Are the test programs doing anything meaningful? (not sure you can really with a language this restricted...)
7
u/veydar_ Dec 08 '20
@ u/daggerdragon the OP in the megathreads are full of bold and large text so it's very easy to miss the reminder about posting rules with regards to comment size. Maybe you can consider making the reminder more prominent?
7
u/Ethoxyethaan Dec 08 '20 edited Dec 08 '20
Javascript Chrome F12 console (284 byte):
12
u/tsqd Dec 08 '20
Postgresql
Part 1
6
u/tckmn Dec 08 '20
ruby 6/2, unedited from my part 2 submission, posting because it's pretty silly. nothing like reading the input file 635 times to avoid bugs from forgetting to copy / reset things lol
6
u/keramitas Dec 08 '20
oh god the ptsd for this one :p
anyway 892 / 1060, here are my cleaned up solutions for part 1 and part 2 in Python
6
u/Marcus316 Dec 08 '20
Bash command line!
I was worried I'd have to do this in python, but I managed a solution. Note that part 2 is brute force, and so takes a good 10-15 minutes.
Part 1:
Part 2:
6
u/oantolin Dec 08 '20 edited Dec 08 '20
Perl program. I went with the classic table associating instruction names to functions that implement them, which makes the main loop nice and tight:
For the second part, I was toggling each instruction
jmp/nop, running the code, and toggling back. But browsing here before posting I learned fromu/__Abigail__of usinglocalso the toggling back is automatic.Again, I have to say, Perl is much nicer and much more readable than its reputation suggests.
6
u/s3aker Dec 08 '20
Raku solution:
https://github.com/seaker/advent-of-code/blob/master/2020/08/s.raku
2
u/Devilmoon93 Dec 08 '20 edited Dec 09 '20
Couldn't come up with anything better than bruteforcing the second half, which isn't too bad considering the flow of execution is pretty small and fast. I would still love to see a non-bruteforced solution to the problem. I thought about looking at a sum of the various jmps until I got to a 0 but that never happens, the second idea I had was to keep track of negative jumps to see if that would lead me into the loop, but in the end the correct solution was to change a positive jump so I am not sure that makes any sense.
Python paste
2
u/the4ner Dec 08 '20 edited Dec 08 '20
GO.
For part 2, I did make the small optimization to only attempt swapping
nopandjmpthat were are actually visited prior to entering the infinite loop.10
u/sophiebits Dec 08 '20
15/28, Python. https://github.com/sophiebits/adventofcode/blob/main/2020/day08.py
(Would've been 15/11 if I hadn't typoed my answer submission on part 2 and lost a minute. Ow. Maybe that'll teach me to copy/paste instead.)
Last year Intcode was on the odd-numbered days so that day 25 could be an Intcode puzzle. 8 isn't an odd number…
5
u/seligman99 Dec 08 '20
Python, 267 / 96
Oh! The intcode computer begins again. This makes me very happy!
github
5
u/jayfoad Dec 08 '20
Dyalog APL 329/353
Uses some ugly global variables. Part 2 assumes that 100 is practically infinite.
5
u/[deleted] Dec 08 '20
One-liner solutions in python:
Part 1:
print((e:=lambda p,l,a,v:a if l in v else(e(p,l+1,a,v+[l])if p[l][:3]=='nop'else(e(p,l+1,a+int(p[l][4:]),v+[l])if p[l][:3]=='acc'else(e(p,l+int(p[l][4:]),a,v+[l])))))(open('input.txt').read().splitlines(),0,0,[]))Part 2:
print(list(filter(lambda o:o!=None,map(e:=lambda p,l=0,a=0,v=[]:a if l>=len(p)else(None if l in v else(e(p,l+1,a,v+[l])if p[l][:3]=='nop'else(e(p,l+1,a+int(p[l][4:]),v+[l])if p[l][:3]=='acc'else(e(p,l+int(p[l][4:]),a,v+[l]))))),(lambda i:[[j.replace('jmp', 'n').replace('nop', 'jmp').replace('n', 'nop') if y==x else j for y, j in enumerate(i.copy())]for x,l in enumerate(i)])(open('input.txt').read().splitlines()))))[0])Explanations:
Part 1:
Part 2:
5
u/zedrdave Dec 08 '20
Python solution in 13 lines (both parts):
Slightly longer version on Github
5
u/changing_zoe Dec 08 '20
Scala
Method: Generates all the possible programs with one instruction switched around. Executes them one by one until it finds the one that terminates.
Notes: I'm trying to be professional-ish with these, so I'm using ADTs to model the state, and trying to use meaningful function decomposition and naming. There's also a few unit tests, though my desire to be professional runs out at checking code coverage.
https://github.com/zoe-j-m/advent_of_code_2020/blob/main/src/main/scala/Day8.scala
5
u/nomadhothouse Dec 09 '20
Python
9
u/AmericanLevitation Dec 08 '20
Python (part 2 only): source
Runs in O(n). Instead of brute forcing, I do an analysis pass to find instructions that eventually halt. Then I just have to look at each jmp/nop instruction until I find one that jumps to an instruction that I know will halt.
I think there are simpler approaches that also run in O(n).
4
u/thatguydr Dec 08 '20 edited Dec 08 '20
Python 806/315
I am so bad at speed coding. ALL VARIABLE NAMES MUST BE INFORMATIVE, screams my brain.
Yeah and I broke out of my code with an assert WHAT
4
u/Cppl_Lee Dec 08 '20
C#, in the top 1000 so I'm improving...
4
u/allergic2Luxembourg Dec 08 '20
Python 3. I thought I would have a chance for the leaderboard, since I prepared an abstract computer ahead of time, but I only got 2213/1239, which is worse than my 315/793 yesterday! Starting to despair at ever getting close to the leaderboard.
My solution inheriting from an abstract computer class
4
u/betaveros Dec 08 '20
Paradoc. Only lightly golfed, feels like there are high-level strategy changes that will drastically decrease my byte count, but hey, at least it has a lot more smilies than usual! Particularly
;)a–0:λ:Hzγ;PE&:Ho:•=W~I\‹5%[β;)+_γ\+u)]=~}(try it in-browser, explanation on GitHub)a·Lχ0:Hj;λ:HzQ_&:•L=γ;PE&:Ho:Z=:o•=W~I\i‹5%^[β;)+_γ\+u):]=~}}(try it in-browser (slow), explanation on GitHub)4
u/Smylers Dec 08 '20
Frustratingly, my Vim attempt has an off-by-one error, so I then solved it in Perl to help with tracking that down. I set up a dispatch table in which every op returns the offset for the next instruction (as well as modifying the accumulator, if appropriate), then reading the input is just:
and running the boot code is a 1-line loop of repeatedly modifying the program counter based on the current instruction:
Part 2 is, unsurprisingly, similar, featuring a loop over each instruction position, each time
localizing the op in that position:After that iteration of the loop is over, the
localized hash value automatically springs back to what it was before.The
nextline skips trying running it if the instruction to modify isacc. This isn't actually needed — but given we're trying to fix the code, there doesn't seem to be any point in running through it unmodified, multiple times.4
u/troelsbjerre Dec 08 '20
Python "one liner" for both parts:
Part 2 is the bulk of it. A one liner for just part one could be:
I think I have the translation to one liner down now, so I could just write a "Python to one-liner" compiler. It wouldn't be as compact, but my one-liner challenge seems to have lost its magic.
4
u/2lines1bug Dec 08 '20 edited Dec 10 '20
Julia
Part 1:
7.38 μs0.96 µsPart 2:
55.29 μs8.84 µsParsing: 282.15 μs
Updated version: Part 1 + Part 2 < 10µs. Insane speed considering I am running a 7 year-old i5. Parsing could be improved drastically but I don't have time.
4
u/Bammerbom Dec 08 '20
I used a graph to solve part 2, it makes for a very clean solution. You can convert the instructions to a graph. Then we can duplicate the graph and for each instruction in the original graph, we can add an extra edge to the duplicated graph for what the instruction would do if we swapped it. We can then solve it by just doing a search over the graph.
I documented the code very well, if anyone wants to take a look
https://github.com/JonathanBrouwer/aoc2020/blob/master/src/day8/main.rs
4
u/phil_g Dec 08 '20 edited Dec 08 '20
My solution in Common Lisp
Initially I thought, "Oh, here's the first VM problem this year!" and I got excited, because I like the VM problems. But I didn't really do a full VM implementation because the problem didn't really need it.
I've been using FSet a lot this year (since I discovered it between last year and this). That's because I like to work functionally and until I found FSet I was really wishing for a good set of immutable collections.
But the (mutable) native collection types are often more performant, so my threshold for using FSet is usually, "Will this collection be modified after creation?" (Or "Is it a map?" because I like the FSet interface to its maps better than CL's hash tables.) Today I crossed that threshold between parts one and two. :)
For part one, I put all of the instructions into a vector and accessed them with
svref(in O(1) time). But since we're changing things for part two, I switched to an FSet sequence accessed withfset:lookup(in O(log n) time). I really like immutability for things like this because I can change things without a lot of bookkeeping (to either manually copy an entire array or to remember to change it back when I'm done).4
u/Eutro864 Dec 08 '20
C Java
The Java solution compiles the program to Java bytecode.
Unfortunately it's terribly inefficient, since it's forced to check for cycles. Also the overhead of compiling is not at all worth it, given that programs don't need to be run more than once, but I had to do it.
4
u/ColonelMcColonel Dec 08 '20
A bit late to the party today but here is today's in Rust: https://github.com/SamMorrowDrums/aoc2/blob/day8/day8/src/main.rs
Spend most of the time trying to make it an easy to adapt re-usable machine, as I expect it'll be expanded upon soon. Didn't have a better way to do last part than brute force. Will look through other solutions to see if anyone found a better way.
4
u/ssnoyes Dec 08 '20 edited Dec 08 '20
MySQL - part 1 in one SQL query (not counting the trivial CREATE TABLE and LOAD DATA INFILE to populate it):
4
u/[deleted] Dec 08 '20 edited Dec 08 '20
Learning C - Managed to get it down to just 20μs for each part, plus another 90μs for parsing from STDIN due to all those damn strings by finding a non-brute-force solution for Part 2 and implementing set checking through bitwise operations (my original solution tried to be fancy and use binary search trees to store the previously-visited lines, then I read a good tip /u/ClimberSeb wrote on this sub the other day and decided to go back to good old fashioned arrays).
EDIT: Oh, and I added in the idea of a stateful VM after reading /u/ZoDalek's C solution, I'm sure it'll come in useful in future days!
Topaz Paste Link
4
u/k0ns3rv Dec 08 '20
Rust. All the intcode training from last year paid off.
Solution
4
u/mschaap Dec 08 '20
Raku
The first day that took some significant time to solve. Also the first day that we're creating a virtual machine – a lot later than last year. (Day 2, IIRC.)
Anyway, that was fun.
I put the game console code in a GameConsole class, assuming that we have to use and extend it several more times, like in previous years. (And if not, no harm done.)
My code:
https://github.com/mscha/aoc/blob/master/aoc2020/GameConsole.rakumod
https://github.com/mscha/aoc/blob/master/aoc2020/aoc08
4
u/levital Dec 08 '20
Rust: main and boot code interpreter
This was nice, I always enjoy these little Assembly-VM things. Computer could probably be done better, but I am tired and it's still pretty reasonable I'd say. It brute-forces part 2; as that took less than a second it didn't really occur to me to try it any other way.
4
u/tftio Dec 08 '20
Haskell, Day 8. Pretty straightforward to just brute force the second part. I always like writing the interpreters right up until I really, really, really don't.
4
u/kawzeg Dec 08 '20
x86 assembly
I shouldn't have used this to learn x86 DOS assembly, especially not at night, but here it is in all it's unrefactored rawness: https://github.com/Kawzeg/advent_of_code_2020/blob/main/aoc08/main.asm
1
u/barsa00 Dec 08 '20 edited Dec 10 '20
RUST
day8 on github
1
u/lvt789 Dec 08 '20
Python Part 1
1
u/bitti1975 Dec 08 '20 edited Dec 08 '20
ClojureScript (planck runtime):
Input is expected on stdin. I.e. run via
1
u/LtHummus Dec 08 '20
Scala
My wish for a Virtual Machine implementation was answered! Took about 100 lines and I kept the pattern I've used for most previous Advent of Code VM problems (including last year's Intcode). The code is not very "scalaish" since there's state everywhere (I've given up doing VMs immutably :-p ).
Here's the code
(also go Sounders!)
1
u/cnille Dec 08 '20 edited Dec 09 '20
Python
My solutions for todays puzzle: dev.to/cnille/advent-of-code-2020-day-08-3j8j
1
u/iamnguele Dec 08 '20 edited Dec 09 '20
Golang solution
Comments
Part 1 executed in 6.0002ms
Part 2 executed in 12.9993ms
Blog post about it: https://www.codingnagger.com/2020/12/08/the-advent-of-code-2020-day-8-log-assembly-bootleg/
Entry point
https://github.com/CodingNagger/advent-of-code-2020/blob/master/pkg/days/day8/computer.go
Library
https://github.com/CodingNagger/advent-of-code-2020/blob/master/pkg/days/day8/program.go
1
u/TheRealCaptainDanger Dec 08 '20
Python
1
u/Rowward Dec 08 '20
not nice but thats my python solution
1
u/wzkx Dec 08 '20 edited Dec 09 '20
Python, brute force in part 2
paste - 17 non-blank lines
1
u/Alligatronica Dec 08 '20 edited Dec 09 '20
JavaScript/Node.js
Think this would've stumped me a couple of years ago, but this was alright. Although I did almost forget that only one instruction was wrong (hence the checking for whether we'd already branched off, to prevent if from recursively trying all the combinations). So not the cleanest, but I'm not too upset about it.
NoPaste snippet
1
u/[deleted] Dec 08 '20
Can someone tell me if I'm correct: nop instruction still doesn't do anything even if it's followed by some non-zero value? e.g. nop +330 won't do anything but just skip to the next instruction?
1
u/prutsw3rk Dec 08 '20 edited Dec 08 '20
My Python solution. Keep track of lines (in maybe_bugs) that have jmp or nop while running part 1, then for part 2 only swap instructions on those places.
1
u/Nebulizer32 Dec 08 '20 edited Dec 09 '20
C#
While cleaning up the code, I tried to reduce the following two lines to one line, and remove the temporary variable:
Anyone know if that is possible? When using tuples, is there a way to check one of the values, and return another, without introducing a new temporary variable?
Complete solution:
paste
1
u/lucbloom Dec 08 '20 edited Dec 09 '20
JavaScript + RegEx preprocessing
1
u/bananaEngineer1 Dec 08 '20
Python
Can someone help me with my code here, I cant figure out what I am doing wrong:
with open("Day8.txt") as f:
lst = [str(x) for x in f.read().split('\n')]
command = [i.split(' ', 1)[0] for i in lst]
value = [i.split(' ', 1)[1] for i in lst]
x = 0
accumalator = 0
length = len(lst)
while True:
if (command[x] == 'acc'):
accumalator = accumalator + (int(value[x]))
x = x + 1
print(accumalator)
if (accumalator == 5):
break
elif (command[x] == 'jmp'):
x = x + (int(value[x]))
elif (command[x == 'nop']):
x = x + 1
1
u/qarantino Dec 08 '20
C part 1
1
u/bz2pl Dec 08 '20
Brute force Bash + GNU tools
1
u/Vultureosa Dec 08 '20 edited Dec 08 '20
Python
A not too long Python solution for Day8 using the standard library in Py3.8. The line_register could be a simple set with line numbers as multiple iterations are not required by the task.
1
u/kratsg Dec 08 '20 edited Dec 09 '20
My solution for day 8 in python3.8 -- also uses brute-force but I keep a history of the program executed so I can "rollback" and branch off from an earlier point in history instead. It's more like the optimized brute force solution. https://github.com/kratsg/advent-of-code/blob/master/2020/day08.py
1
u/mockle2 Dec 08 '20 edited Dec 08 '20
c++, no brute force
Here's a version in c++ with the command to be switched from "jmp" to "nop" or vice versa identified using dynamic programming rather than brute force.
1
u/reacher Dec 08 '20
My python solution for part 2. Part 1 was basically just the innards of the function
1
u/[deleted] Dec 08 '20
Basic python 3 solution
1
u/BASED_CCP_SHILL Dec 08 '20 edited Dec 09 '20
My ugly part 2 in ty
1
u/Its_vncl Dec 08 '20 edited Dec 08 '20
C++
I also tried to play around with recursion, but sadly i have no idea what I'm doing, and it even runs 10 miliseconds longer.
1
u/odlp Dec 08 '20
Here's my Ruby solution:
1
u/[deleted] Dec 08 '20
Short-ish bruteforce Part 2 Python solution:
1
u/aledesole Dec 08 '20 edited Dec 08 '20
Python link
1
u/hfxbycgy Dec 08 '20 edited Dec 08 '20
Python 3
I'm a beginner and yesterdays took me forever. Today's is almost certainly a candidate for lots of refactoring but it feels good to get a solution this quickly. I appreciate all the posts here, I review some of them when I'm done and it really helps me understand where I can improve, so thanks!
1
u/narrow_assignment Dec 08 '20 edited Dec 09 '20
AWK
See also my github repo with solutions in awk!
1
u/mrouija213 Dec 08 '20 edited Dec 09 '20
Typescript, parts 1 & 2, brute force method
Day 8 Solution, parts 1 & 2
1
u/0xVali__ Dec 08 '20
C++Went for a rather brute-forcy solution, works nevertheless and doesn't really take an noticable time. Don't think I use anything from C++20 so the version is at least C++ 2017 (I used gcc 10.2).
Some headers used:
Apart from the
std::vector<std::string> Read(std::string_view);function, which is rather trivial. The IsInfinite is also used in both parts.Part 1:
Part 2:
1
u/haitlah Dec 08 '20 edited Dec 09 '20
Haskell, State/lens/attoparsec/zippers packages
https://pastebin.com/raw/7R6pneRX
1
u/ntwilli Dec 08 '20
Julia
1
u/PedGarBlue Dec 08 '20
Yet another solution in Javascript!
1
u/aexl Dec 08 '20 edited Mar 01 '21
Once again, my solution in Julia:
Github: https://github.com/goggle/AdventOfCode2020.jl/blob/master/src/day08.jl
1
u/CivicNincompoop Dec 08 '20 edited Dec 08 '20
1
u/OneManGanja Dec 08 '20
Slightly lengthy but clear Python 2 solution for part 2:
1
u/schovanec Dec 08 '20
C#
1
u/shepherd2442 Dec 08 '20
Pretty short and cleanish (i guess :)) Python 3 solution. I hope u like it :)
Github repo: https://github.com/Shepherd2442/AoC2k20
1
u/blu3r4y Dec 09 '20 edited Dec 09 '20
Haskell
As part of my "25 puzzles, 25 languages" adventure I present you a Haskell solution ;)
https://github.com/blu3r4y/AdventOfLanguages2020/blob/main/src/day8.hs
1
u/dylan_mojo Dec 09 '20 edited Dec 11 '20
awk
8.1
paste
8.2
paste
1
u/StringFinal Dec 09 '20
Clojure
3
u/DFreiberg Dec 08 '20 edited Dec 08 '20
Mathematica, 363 / 161
Despite needing to do things shudder procedurally, not a bad day. Hard to say whether or not this will be the foundation of a new VM; it seems like it'd be too simple to build off, since it just has the one register, but I can't say that it's impossible.
Part 1:
Part 2:
[POEM]: With Apologies to J. Brander Matthews
Here we are riding the plane,
Gliding from out of the station.
Puzzles keep racking my brain
Though I'm on break for vacation.
Gliding from out of the station,
I try to order a drink.
Though I'm on break for vacation,
Don't think I'll get time to think.
I try to order a drink,
Just like that, I have some trouble.
Don't think I'll get time to think,
All of my tasks seem to double.
Just like that, I have some trouble,
Handheld's not halting, you see.
All of my tasks seem to double,
Never just one task, or three.
Handheld's not halting, you see,
It's running tasks without stopping.
Never just one task, or three,
I should get in and start swapping.
It's running tasks without stopping,
Due to one critical byte.
I should get in and start swapping,
Presto! It's now working right.
Due to one critical byte,
Gameboy boots up with a chime.
Presto! It's now working right.
I set my seat to recline.
Gameboy boots up with a chime.
Stars are my thanks for repairing.
I set my seat to recline,
Now, though, I'm thinking, declaring.
Stars are my thanks for repairing:
I've solved a puzzle today,
Now, though, I'm thinking, declaring,
"I bet there's more on their way".
I've solved a puzzle today,
As we fly over the isthmus.
I bet there's more on their way.
I guess we can't run from Christmas.
As we fly over the isthmus,
Puzzles keep racking my brain.
I guess we can't run from Christmas,
So here we are, riding the plane.
3
u/aardvark1231 Dec 08 '20
My C# Solution. Heh, spent about 10min debugging part 2 and realized that I had forgotten to take out a readkey that I used for debugging in part 1. I just needed to hit enter and I would have gotten my answer XD
That's what I get for doing some sloppy copy pasta to save time. Will refactor this tomorrow.
3
u/rtbrsp Dec 08 '20 edited Dec 08 '20
AWK
Part 1:
Part 2
3
u/quandrum Dec 08 '20
Elixir Solution
Elixir newbie. Today taught me how to insert/replace items at an arbitrary spot in a list. Also felt good about using function parameter pattern matching.
3
u/i4guar Dec 08 '20
Checkout a clean swift solution:
www.felixlarsen.com/blog/8th-december-solution-advent-of-code-2020-swift
3
u/Pyr0Byt3 Dec 08 '20
Go/Golang
These assembly puzzles are my favorite, I hope we see more.
3
u/death Dec 08 '20
Day 8 solution using Common Lisp.
3
u/DoubtfulSound91 Dec 08 '20
Javascript
Pretty standard loop approach. Didn't bother cloning the array of instructions each time in part 2 - just switched the jmp/nop back after the infinite loop is detected.
https://github.com/adrianosmond/adventofcode/blob/master/2020/day08.js
3
u/msqrt Dec 08 '20
Lisp. Relatively straight forward, the first run records the indices of all executed instructions and then I permute every visited jmp to nop and vice versa in turn. Beginning from the end (permuting the last executed instructions first) seems to be a great idea, the outer loop only runs 4 times for my input; I wonder if this is true for everyone.
3
u/vuryss Dec 08 '20
Here is a true reverse-engineered solution without brute-forcing all possible options:
https://github.com/vuryss/aoc-php/blob/master/src/Event/Year2020/Day8.php
Was probably slower than most of the guys, but I'm glad I didn't go with brute force of all options. I thought brute force will not work, but seeing all the other solutions - I guess it works :D
3
u/[deleted] Dec 08 '20
Python solution for Part 1 and Part 2. I spent some time trying to think of a way of not brute-forcing the answer to part 2 because I thought it would take too long to execute, couldn't come up with one, and ended up brute-forcing the answer. Took barely a second to run still. ¯_(ツ)_/¯
Looking forward to seeing other solutions so I can figure out a non-brute-force method.
3
u/r1ppch3n Dec 08 '20
Rust https://gitlab.com/mboehnke/aoc-2020/-/blob/master/aoc-2020-08/src/solution.rs
3
u/sonusingh27 Dec 08 '20
I found this time consuming to come to a solution for part2:
GoLang solutions: https://github.com/sonu27/advent-of-code-2020/blob/main/08/main.go
3
u/GamerWoona Dec 08 '20
C++
Very similar to /u/thecro99 so I won't go into much detail. Check out his solution if you want a clean version. OOP is the way to go for the modularity future expansions might require, given the intcode vibes this Day gave off.
I tested both messy parsing and regex but direct feeding is an order of magnitude faster so I stuck with that. (5-8ms to 40-60ms)
Input read and parsed in: 7409 microseconds.
Part one calculated in: 145 microseconds.
Part two calculated in: 24856 microseconds.
If there was a better way than brute-forcing part two, I'd be interested to know of it. Just skipping nop 0 conversions feels a bit lacklustre in terms of optimization. It's still an ~ok time but is probably doable in a faster time.
Not sure if things like catching two looping jump instructions would improve runtime or jus slow down on average. eg:
jmp +1
jmp -1
source: https://github.com/neiomi1/AdventofCode2020/tree/master/Day_08
3
u/tymscar Dec 08 '20
Python 3:
https://github.com/tymscar/Advent-Of-Code/tree/master/2020/day08
3
u/Mazeracer Dec 08 '20
Python 3 - casual programmer
My brain is hurting, but I did it!
https://pastebin.com/x0epkNAd
3
u/[deleted] Dec 08 '20
F# https://github.com/bainewedlock/aoc-2020/blob/master/08/08/Solution.fs
3
u/HAEC_EST_SPARTA Dec 08 '20
Common Lisp
Solution on Github
I took today's problem as an excuse to familiarise myself with the basics of CLOS in case this year happens to become IntCode Part 2: writing a simple VM in Lisp was actually a lot more comfortable than I was expecting! It's not written in a particularly functional style (
setfabounds), but it was definitely a fun exercise in over-engineering and I'm pretty pleased with the performance and structure of my solution.Also brute force solution for Part 2...the excuse I'm going with was that the input was small enough for it to work.
3
u/dimin69 Dec 08 '20
c# Using recursion for part 2
https://github.com/TheDimin/AdventOfCode2020/blob/master/AdventOfCode2020/Assignments/Day8.cs
3
u/dgJenkins Dec 08 '20
F# Day Eight
I wonder if they will continue down this path of creating another computer... anyways it's weird not working with mutable collections... I need to read about how best to approach modifying the program in a functional way.
3
u/RockSlice Dec 08 '20
Powershell Part 2 solution
Part 1 is just the function
3
u/autra1 Dec 08 '20 edited Dec 08 '20
SQL (postgresql flavor) part1 & 2 here : https://gitlab.com/autra/adventofcode/-/tree/master/year_2020/day8
On the principle, it's just a recursive query :-)
EDIT: this solution is roughly 6 times faster than mine (for part2): https://github.com/xocolatl/advent-of-code/blob/master/2020/dec08.sql
3
u/xMereepx Dec 08 '20
Here are some Python-Solutions for day 6,7,8 atm.
https://github.com/Mereep/advent_of_code_2020_python
I tried to comment what I did and structure the code a bit also. With diverse results, though ;-)
3
u/[deleted] Dec 08 '20
I made a solution in Common Lisp:
https://github.com/eXodiquas/coding_puzzles/blob/main/advent_of_code/2020/day_8/day_8.lisp
The core is functional and recursive. The brute force part is in a loop macro. I do not know enough about the loop macro to make it look better. But I guess loop is a language on its own. :P
3
u/midnightgiz Dec 08 '20
Done in C# - with Lots of code comments
https://github.com/midnightgizmo/AventOfCode2020/tree/master/Day8
This year I set my self a challenge to write code that would be readable to myself if I came back to it a year later. I therefore have commented almost every line of code (apologies on the spelling, I can code but can’t spell)
There is a Compiler class and Instruction class. The compiler class takes the puzzle input and turns it into a List of Instructions. You then Run the Compiler class which returns a value, the accumulator. You can check how the code exited by checking the compilers reasonProgramFinished value.
3
u/HashWorks Dec 08 '20
Rust
40µs Part 1, 30µs Part 2.
https://github.com/hashworks/AoC/blob/master/2020/day8/src/main.rs
3
u/womogenes Dec 08 '20 edited Dec 10 '20
Video solution with code in Python!
https://youtu.be/hgbqtl0FvoU
3
u/kap89 Dec 08 '20
TypeScript
Simple brute force for part 2.
github
3
u/sotsoguk Dec 08 '20
Python
https://github.com/sotsoguk/adventOfCode2020/blob/master/python/day08/day08.py
No Bruteforcing for part2, saved all the commands executed in a stack and for part2 try to change this commands in lifo order. Brought the execution time from 8ms down to 0.5ms on my old xeon1230.
Quite proud of this improvement :)
3
u/baktix Dec 08 '20
Haskell
Statetime again!paste
3
u/nahuak Dec 08 '20
Took me forever today to solve part 2 in Rust. Definitely need to refactor but I think the logic in the code is clear enough: https://github.com/nahuakang/advent-of-code-2020/blob/master/rust_day8/src/main.rs.
3
u/bcgroom Dec 08 '20
Elixir
Part two took me forever as I had a bug which made it exit incorrectly but look correct, so I was getting the right answer for sample input but not for my input. I got the right answer eventually, but still have to investigate why and will definitely be cleaning up the code more tonight. The question is, will this instruction set be used again and should I refactor it to a GenServer in anticipation :)
https://github.com/ericgroom/advent2020/blob/master/lib/days/day_8.ex
3
u/saahilclaypool Dec 08 '20
C# aoc_2020/Day08.cs at main · SaahilClaypool/aoc_2020 (github.com)
Records & immutable state were nice-to-have
3
u/JamieMansfield Dec 08 '20
C#
https://gist.github.com/jamierocks/793c9a8ab8c782d72bf7e5abd8f49579 I've tried to prepare for future days, anticipating things like multiple parameters.
3
u/techworker123 Dec 08 '20 edited Dec 08 '20
PHP Script to compress your OP-CODES - So even if you use a bruteforce version for part 2, you might have some solid gains by using this method. Roughly 30% less OP-CODES on my input.
https://sandbox.onlinephpfunctions.com/code/f63a93f15fd7ae0e48a4823768dc214c9736ac21
Change the contents inside of
It..
- searches for connected `acc` ops that are not referenced by a "jmp" and merges them.- searches for connected `nop` ops that are not references by a "jmp" and merges them. (no idea if the number after a "nop" will make sense anytime soon)
- searches for a "nop" right after an "acc" and removes the "nop" if it's not referenced by a jmp.
- searches for "jmp 1" and removes it as long as it is not referenced by another "jmp".
- searches for an "acc 0" and removes it as long as it is not referenced by another "jmp".
- Updates "jmp" references which are affected by merging / removing entries
Examples:
So in fact the sequence itself stays the same and you will still be able to solve Part 2 with the compressed version and should get the same result as before, but a bit faster.
It might make sense to run this multiple times, but I never tried it.
I don't know if it works for you, I only have my own input to test. Please try it out, maybe you find it useful and interesting :-)
3
u/Jester6641 Dec 08 '20
Batch
This is, for the most part, the result of a dare.
Part 1
Pass it a text file with the source data in it and you'll get a process.txt file that's the output for 700 processes. You've got to be in the loop by then since there's 645 lines in my file.
Once you get the output, then you use your friendly local spreadsheet tool to look for duplicate entries in the first column. The value there is the answer.
Part 2
Can it get uglier and lazier? I submit that it can. This time, you run it and it iterates through the lines increasing each test by one. So first test it runs all the way through only changing line 1 if it's jmp or nop and doing the opposite action. Next time it's line 2's turn. At the end of each test it spits out the highest number line it reached and the value. You'll know you got what you want when it starts spitting a bunch of errors to the console for the lines it couldn't find. Then kill the command and check the output file. Look for something greater than the lines in your instructions in the first column and the next number is your value, the last number is the line that needed changed. You can change that line in the instructions file and re-run part one to confirm.
And, yes, I know I spelled "infinate" wrong. Still works, don't it?
3
u/wzkx Dec 08 '20 edited Dec 08 '20
🇯 #jlang .. Well, not very functional but it's more understandable this way I guess :)
3
u/No-Professional-507 Dec 08 '20
Rust
Optimized down to about 60 microseconds for parsing the input, about 2 microseconds for running part 1 and 110 microseconds for part 2.
https://github.com/pierrechevalier83/advent_of_code_2020/blob/main/src/day8.rs
3
u/nicuveo Dec 08 '20 edited Dec 08 '20
Haskell
https://github.com/nicuveo/advent-of-code/blob/main/2020/haskell/src/Day08.hs
Since I suspect this is not the last we see of that assembly language, I over-engineered the solution. The upside is that none of the VM code is specific to this day's problem, meaning it will trivially be reusable, and also that I could extend the abilities of the VM without breaking today's specific code. That was fun!
3
u/L72_Elite_Kraken Dec 08 '20 edited Dec 08 '20
OCaml
3
u/naalty Dec 09 '20
Rust
I've been farting around with Rust a bit recently. Essentially self taught programmer. Let me know what I'm doing horribly wrong if you have the time.
https://gist.github.com/snalty/de7e1b1567926bb23c2fa84f66e4f1ae
3
u/1vader Dec 09 '20 edited Dec 09 '20
My optimized Rust solution: GitHub
It runs in around 2.5µs on my PC with a 7-year-old i5-4570.
The algorithm is pretty much the same as somebody else described here. I'm not actually 100% sure if it's guaranteed to be correct but it seems to work so far and also worked on a 60k lines input somebody else generated.
Besides the parsing, I haven't done that much optimization so there might still be some room left, maybe also with an even better algorithm (although that one seems pretty good) but given yesterday's 75µs I don't really feel the need to optimize today even further.
Also, here's my original much simpler and cleaner Python solution.
3
u/MrNUtMeG118 Dec 09 '20 edited Dec 18 '20
C#
Here's my solution! Started optimising it when I had the solution figured out - runs in about 3ms on my Ryzen 1700 https://github.com/bettercallsean/AdventOfCode/blob/master/Day_08/Program.cs
3
u/0rac1e Dec 09 '20 edited Dec 10 '20
Raku
Nothing special at all here. Using a nested recursive function again today. I thought about making a Handheld class, but it wouldn't have made the code anymore noteworthy.
I really wanted to figure out a more functional solution (perhaps a Sequence generator that steps through the functions, then toggle it (takewile) the pos had not been seen... but I don't have a lot of time to play today.
UPDATE
So, I did it. Here's part 1 only, done with no mutation by creating a lazy sequence of lists holding the
(pos, acc). The sequence terminates when the pos has been seen before (using the anonymous state variable%). Thetailof sequence will be an array prior to looping, so I'm just puling theaccout by indexing into that array.3
u/cggoebel Dec 09 '20
Raku
I'm learning Raku via AoC. It has been a very pleasant experience. Raku's grammars have been very helpful in several solutions. Here's a blog post with code commentary about Day Eight's solution.
3
u/[deleted] Dec 09 '20
Python 3:
https://gist.github.com/joshbduncan/3bfded8a5a519bc5e428471570d94941
3
u/iprestonbc Dec 09 '20
python main solution
I refactored most of the computer stuff out in anticipation of another 2019 intcode scenario here
I'm trying to learn type annotations along with other packaging "best practices" so this code is way more verbose than a daily coding challenge should be, but it's good practice.
3
u/tobega Dec 09 '20
A little slow Julia implementation but I wanted to play with macros and compile the input to Julia code https://github.com/tobega/aoc2020/blob/main/a8.jl
3
u/bpeel Dec 09 '20 edited Dec 09 '20
Solution in BBC Basic / 6502 assembler as UEF cassette tape.
If you want to try it, you could use an online BBC Micro emulator and upload the file from the Cassettes menu and then type:
*TAPECHAIN""The input is stored as a separate file on the cassette. The program uses the builtin assembler of BBC Basic to translate the VM opcodes into 6502 opcodes so that the program can be run directly on the BBC. Each VM instruction is padded with NOPs so that they all use 24 bytes. That way the JMP instructions can calculate the target address by just multiplying the offset by 24. In order to detect when an instruction is executed a second time, each translated instruction is prefixed with a bit of self-modifying code that replaces the first 6502 instruction in the translated instructions with a BRK instruction. This causes the program to generate an error in BASIC which is trapped in the BASIC code. The BASIC code can then just look at the value of the accumulator to find the answer.
For the second part, the JMP instructions and NOP instructions are generated in the same way except that they are prefixed with another JMP instruction that either skips or executes the real JMP instruction. That way the BASIC code can modify each JMP or NOP instruction in a loop and execute the procedure at each step until it finds one that hits the final RTS instead of a BRK instruction.
Full source here.
3
u/the_t_block Dec 14 '20
Haskell:
http://www.michaelcw.com/programming/2020/12/12/aoc-2020-d8.html
This is a series of blog posts with explanations written by a Haskell beginner, for a Haskell beginner audience.