December brings another once-a-year phenomenon for computer enthusiasts: the arrival of a new set of programming puzzles at a site called Advent of Code.
“Every year, Eric Wastl creates 25 two-part programming puzzles, all connected together by a cute story about needing to save Christmas,” explained Tanya Reilly, principal engineer at Squarespace, in a recent blog post describing the phenomenon. “But the real fun is when you’re doing them in December as they appear, one every day, with a community of thousands of other people solving them at the same time.”
But that large community has also brought an unusual set of technical challenges, which Wastl manages each year with determination and dedication — and a little help from the cloud.
Throngs of devs eagerly await each new puzzle’s arrival at midnight, counting down the days until Christmas, and over the last six years it’s developed a large following of enthusiastic fans. “The factor that makes it stand out for me is the community,” posted one fan on Hacker News. “The r/adventofcode subreddit is very active every year and not only can you learn programming tips and tricks from others but you can also see people doing crazy things like solving problems in tools like Excel, Git, etc. and cool visualizations of their solutions.”
This year 18,700 fans have subscribed to its dedicated forum on Reddit, which is filled with posts showing off clever and creative solutions.
Because there’s a large community solving the same puzzles, there’s a ready-built audience for these timely feats of coding creativity. And the site’s fans solve its puzzles in a dazzling variety of programming languages, from Smalltalk to Haskell, Clojure, and Raku. Solutions have been posted in Java, C#, Go, Rust, Kotlin, Lisp, Swift, and even Powershell.
One machine learning researcher is trying to calculate their solutions using Tensorflow. Someone posted solutions they’d written in Assembly. Someone actually solved a puzzle by creating a custom command for Apple’s Siri voice assistant. At least four different Reddit users created animated images depicting their solutions (with one using Ascii art). And someone else solved the same puzzle in an Excel spreadsheet. Someone has posted a solution done in Game Boy assembly language, and in the educational visual programming language Scratch.
Has Wastl ever been shocked by how fast his fans solve one of his puzzles? “All of them, every night,” he told his audience on Twitch.
Behind the Magic
On Twitch, Wastl said he was inspired by the advent calendars he’d enjoyed growing up. An advent calendar counts the days leading up to Christmas. Wastl was also spurred by “a love of helping people learn. A love of programmer education.” Some people have told him they’ve gone from solving his puzzles to a career in programming. “That’s the coolest story to me. Just to give somebody the ability to go and chase their dream like that is all I want.”
As you do #AdventOfCode this year, please remember to be kind to each other and to yourself; everyone is at a different place, and things that are easy for some people are hard for others. Focus on improving yourself, and be supportive of others as they try to do the same. 🌟
— Eric Wastl (@ericwastl) November 25, 2020
On Twitch Wastl said with a smile that the two-part puzzles mimic the all-too-familiar real-world phenomenon of changing requirements — but it’s a chance to experience them in a low-pressure environment.
As Squarespace’s Reilly explained, “Santa-related puzzles don’t inspire the most beautiful, production-ready code.” But ultimately, that’s part of the event’s unique charm. “Tech is a profession fraught with status anxiety and egos, so there’s something warm and vulnerable about people coming together to show off their most terrible code. I love that.”
The year 2020 hasn’t changed his process — except in the sense that “everybody’s home because of Covid,” Wastl explained Thursday on Twitch. “So they’re doing Advent of Code instead — so they hugged the servers to death.”
In 2019 the first day had seen a 20% increase in traffic from the year before, so he’d tried to plan for another increase in traffic in 2020. But when the big day came there was a massive 150% increase which quickly lead to overloaded servers.
The first puzzle was launched on Dec. 1 — and within 48 hours, more than 86,000 people had completed it. That many users is really hard to visualize, Wastl admitted later on Twitch. “It’s not a number your monkey-brain can solve.” This number was more than the total number of solvers for all of 2015.
“Guess what happens if your servers have a finite amount of memory, no limit to the number of worker processes, and way, way more simultaneous incoming requests than you were predicting?” Wastl explained in a post-mortem. “That’s right, all of the servers in the pool run out of memory at the same time. Then, they all stop responding completely. Then, because it’s 2020, AWS’s ‘force stop’ command takes 3-4 minutes to force a stop. Root cause: 2020.”
When a comment on Twitch posts that big services are built on failures and post-mortems, Wastl is quick to agree — a point he reiterates in some telling advice for anyone wanting to try to launch their own wide-scale event. “Fail a lot, make a lot of mistakes. And every time you make a mistake… understand it, internalize it, fix it, add monitoring for it — and then off you go.
“And then wait for the next thing to break, and then do it again.”
Labors of Love
Wastl spends a good chunk of the year dreaming up puzzles. “Preparing a new calendar and a new set of puzzles each year takes all of my free time for 4-5 months,” Wastl explained, in a secret message hidden in the site’s HTML code. “A lot of effort went into building this thing — I hope you’re enjoying playing it as much as I enjoyed making it for you!”
On Twitch Wastl said he’s almost constantly working on puzzles, and is always updating his “humongous” list with “hundreds and hundreds of puzzle ideas.” One 2016 puzzle was inspired by a defcon talk about spewing instructions into a mysterious chip to decode how it works.
Wastl still tries to finish early so his beta testers have time to test the puzzles. They always identify which inputs have edge cases — but also surprise him by which ones they’d found most difficult. When asked if he needed more beta testers, he had a familiar answer. “No, I need fewer beta testers. I get so much feedback… it takes me forever to go through what the beta testers say.”
— Jeremiah Simmons (@jtsimmons108) December 1, 2020
It was minutes away from midnight as his audience on Twitch watched, and Wastl suggested they do one more thing “before i go to watch the servers and breath into a paper bag.” He asked everyone watching his stream to switch over to another Twitch livestreamer — in this case, Lyft software engineer Anthony Sottile, who at that moment was streaming on a channel called Anthony Writes Code.
And just like hundreds of developers around the world, Anthony was hovering over the Advent of Code page waiting for the next puzzle to appear.
He was streaming his attempts to solve all the puzzles in SQLite.
- This year’s Donald Knuth Christmas lecture is canceled — but some past talks have been posted online.
- America’s post office tries a digital nationwide “Operation Santa.”
- Podcaster interviews 78-year-old Brian Kernighan about the birth of Unix.
- Will the world’s next transformation trove of information be unlocked by “Vision AI“?
- The quest continues to build a truly open ebook reader.
Feature image by congerdesign de Pixabay.