Awkward solutions to Advent of Code challenges

In day 6 of the 2019 Advent of Code edition, we are presented with a system of objects orbiting in space. All objects orbit the center of mass of the system (modeled as object COM), either directly or by orbiting a larger object.

COM)B  # B orbits COM
B)C    # C orbits B
C)D    # D orbits C

These chains of orbits can be solved as a directed graph. It just so happens that the old Unix toolkit has tools to operate on directed graphs. They aren’t designed for the use that we will make of them, but that’s what makes this fun.

Continue reading “Awkward solutions to Advent of Code challenges”

Jobs and pipes

I just watched one of Gary Bernhardt’s excellent screencasts, Tar, Fork and the Tar Pipe. It’s a succinct and powerful overview of key Unix concepts and I highly recommend watching it. If you’re new to Unix, it can be an eye-opening, refreshing look at computing. If you’re seasoned, Bernhardt’s fine execution is still a delight to watch.

While on that topic, I thought I could share some toy code that I’ve had lying around since last year. I will take the time to explain the process, hoping that in the end the result will, it too, seem refreshingly simple.

Continue reading “Jobs and pipes”

Superposition & Indetermination

Or: The List Monad

Last year, I introduced monads under a more “intuitive” light—focus was placed on the semantics of monads rather than formal definitions, turning to the Maybe monad as a first contact. The following assumes the reading of said article.

Continue reading “Superposition & Indetermination”

Functors & Monads: An Introduction

Following some in-person chats on a number of concepts of functional programming, my team pushed me to try to share and present some of these to a wider audience. Admittedly, finding online resources on FP that are both palatable and reasonably sized is not always easy. This article was written in December 2015 and was my best attempt—in my own perspective and with my own analogies—to talk about what lies beyond the obscure term monad by starting with functors.


Continue reading “Functors & Monads: An Introduction”

Of vocabulary and contracts

I was asked why one should prefer map over for.

Here’s an analogy: why do we, as a talking species, use different layers of vocabulary? Why do we have abstract terms in our language, as opposed to only concrete terms drawn from tangible things from our physical world? I mean, the Romans did fine without abstract language, right? Or were they limited by Latin? Wasn’t the incredible boom of philosophical thought during the Enlightenment facilitated by the abstraction powers of the German language?

Continue reading “Of vocabulary and contracts”