m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/blog
diff options
context:
space:
mode:
Diffstat (limited to 'src/blog')
-rw-r--r--src/blog/advent-of-code-2020.html91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/blog/advent-of-code-2020.html b/src/blog/advent-of-code-2020.html
new file mode 100644
index 0000000..3b78433
--- /dev/null
+++ b/src/blog/advent-of-code-2020.html
@@ -0,0 +1,91 @@
+title: Advent of Code 2020
+date: December 25, 2020 17:35
+---
+<p> Merry Christmas to all!</p>
+
+<p>
+<a href='https://adventofcode.com/2020'>Advent of Code 2020</a> has come to an
+end. At the time of this writing, around seven thousand people finished the
+whole thing, out of the 150000 that had submitted a solution to the first day's
+problem. And I'm one of them!
+</p>
+
+<p>
+You can see my solutions <a href='https://gitlab.com/m-chrzan/aoc2020'>here</a>.
+I started out with C, moved on to Ruby, and near the end switched to Lua. I'm
+going to need some Lua knowledge for the Redis section of the databases class
+I'm taking right now, so AoC was a good time to get familiar with the language.
+</p>
+
+<h3>Thoughts on AoC 2020</h3>
+
+<p>
+I found most of the problems fairly simple, but it was fun to go through them
+all anyways.
+</p>
+
+<h4>Most Tedious Award goes to...</h4>
+
+<p>
+<i>Day 20 Part 2</i>. My solution ended up being a good 340 lines of Lua split
+between two scripts. This is the last problem I solved because I knew it would
+require a lot of work to get working, so I procrastinated on it until the end.
+</p>
+
+<p>
+In the end, the process of solving this was actually kind of fun, and getting
+the final solution satisfying. I think it might have something to do with the
+geometric/visual nature of the problem. There's just something nice about
+rotating and flipping ASCII squares with code, and seeing them all line up
+correctly in the end.
+</p>
+
+<h4>Most Cheesed Award goes to...</h4>
+<p>
+<i>Day 19 Part 2</i>. Rather than implementing a parser generator that could
+handle this grammar by hand, I bodged together a
+<a href='https://gitlab.com/m-chrzan/aoc2020/-/tree/master/19/b'>
+ Bison (aka Yacc) solution
+</a>. It's not very pretty, especially the Bash script that just calls the
+parser with each input word separately and counts how many times it didn't exit
+with a syntax error. But it works! And I finally learned something about
+Bison/Yacc and Flex/Lex, which I've had indirect exposure to before, but never
+actually used.
+</p>
+
+<p>
+I was quite pleased with my Part 1 solution though, where I implemented a simple
+recursive parser generator.
+</p>
+
+<h5>Runner-up in the Most Cheesed category</h5>
+<p>
+<i>Day 13 Part 2</i>. I'll admit it, I just copied a Chinese Remainder Theorem
+implementation from Rosetta Code. I'm sure the Python guys just used
+<code>numpy</code>'s CRT, so treating it as a library function doesn't seem too
+cheaty for me.
+</p>
+
+<h4>Most Fun Award goes to...</h4>
+<p>
+Probably a tie between the already mentioned <i>Day 20 Part 2</i> and <i>Day 19
+Part 1</i>. Day 20 had that cool geometric component and satisfaction of
+putting a puzzle together, but I'm a sucker for recursive parsers implemented
+with higher order functions.
+</p>
+
+<h3>Thoughts on Lua</h3>
+<p>
+Learning Lua was probably the most useful outcome of this year's AoC for me. I
+feel pretty comfortable with the basic constructs of the language, and even
+played around a bit with metatable-driven OOP. I don't know how closely I stuck
+to general conventions, and didn't interact with any external libraries, but can
+definitely read and write the language comfortably now.
+</p>
+
+<p>
+My one sentence summary of feelings towards Lua is that Go is to Java what Lua
+is to Python/Ruby/JavaScript. Its very small vocabulary means you learn the
+language quickly and don't need to think much while writing it, but your
+programs can end up more verbose than the equivalent Ruby/Python.
+</p>