highlights
Nov 24, 2024

🎁 These are a few of our favorite things

Rebecca Mark

Advent of Code is a yearly event that challenges programmers to solve a series of puzzles in the days leading up to Christmas. Unison programmers have a wonderful history of documenting their solutions for others to follow along.

Last year, we featured the many Unison solutions to the Advent of Code puzzles in our holiday card. Here's a recap with links to some of our favorite solution guides in case you missed it!

2023 Advent of Code Highlights

Day 1

Day 1: Trebuchet features an excellent List pattern matching demo by @gfinol while @rlmark discusses combining the Parse and Ask abilities to reduce boilerplate when writing Unison.

Day 2

Day 2: Cube Conundrum, features @kemiller writing up a solution using Lists with a clever use of uncollate, a little known standard lib function. @jcwilk sums up this day nicely, "It was a lot of fun to explore how to best leverage folding and pattern matching to solve these problems." Calls to foldMap abound!

Day 3a

For Day 3: Gear Ratios, @ceedubs produced a beautiful explanation of his solution. It even includes mermaid diagrams using another Unison library by @alvaroc1 to better display the problem. @systemfw offers us a pro-tip about representing matrices as Map values, and leverages the Each ability in his algorithm.

Day 4

Day 4: Scratchcards has the Unison community sharing some wisdom when writing parsers. @cpenner's writeup includes a lesson on backtracking in parser combinator libraries and @systemfw and @rlmark sing the virtues of writing small parser combinators to test iteratively. @kemiller and @systemfw use two of Unison's data structures optimized for natural numbers, NatSet and NatMap, respectively.

Day 5

In Day 5: If You Give A Seed A Fertilizer, @systemfw explored some optimizations. From his Readme: "I couldn't keep ucm churning all day since I had to...you know, work." Instead, his implementation explores an Interval map for greater efficiency. @jcwilk's writeup discusses the process of writing Unison programs itself, "I was able to follow a pattern of leaning hard into composition, building tiny one-line functions, and relying heavily on the typing system to assert correct program behavior."

Day 6

For Day 6: Wait for it, @stew's lovely solution includes play-by-play descriptions of the functions which constitute his solution and a discussion wherein he uses mathematical reasoning to cut down on the problem space. Thank you @stew!

Day 7

Day 7: Camel Cards includes a pattern matching primer by @hagl, who exercises tuple decomposition, list pattern matching, and pattern guards in his algorithm! @systemfw's work includes a great discussion about when to use custom types or rely on more primitive abstractions in a language. Both are very educational reads!

Day 8

Day 8: Haunted Wasteland, was a challenging day! @systemfw boldly went where many feared to tread and his solution discusses, among other things, the vicissitudes of cycle detection! It's wonderful to follow along with his problem solving process.

Day 9

For Day 9: Mirage Maintenance @dvberkel relates the problem to one which Douglas Hofstadter (of Goedel Escher Bach fame) studied. Very cool! He also uses a custom domain Sequence type to help clarify the problem space. It makes for a very readable writeup. Both @johanwinter and @kemiller explore more of the standard library, with lots of folds and unfolding over lists.

Day 10

We love @ceedubs writeup for Day 10 because he takes the time to walk s through his problem solving logic and edge cases with humor and wisdom. It includes an interlude where he takes a walk away from his computer and he returns with a ray-casting inspired solution! Eureka!

Day 11

To solve Day 11: Cosmic Expansion, @systemfw uses a Map based representation of the X,Y grid again. Unison's Map standard lib utility functions offer a rich set of options for this solution. We love @hagl's write-ups because he includes links to the helper functions that he adds or finds useful in the standard lib. This solution used "allPairs," which is a function we'll keep in mind for generating pairs from a list.

Day 12

In Day 12: Hot Springs, @hagl used a handy library for memoization to cut down his runtime from 7 hours (yay! an excuse to sleep!) to less than 4 minutes. @systemfw brought out the heavy artillery for the solutions for day 12, using both dynamic programming and parallelism. Any time we get the chance to listen to Fabio about concurrency, we'll take it!

Day 13

For Day 13: Point of Incidence, @systemfw's solution writeup includes some beautiful ascii art to help explain his algorithm and also breaks down some efficiency shortcuts for part 2 of the problem.

Day 14

For Day 14: Parabolic Reflector Dish, @systemfw wrote a Shakespearean play in 5 acts. Just kidding! No really, there is a whole introduction section to the problem, a section dedicated to the core algorithm, and two sections dedicated to writing a custom memoization ability and ability handler. Truly a masterclass!