Blog

Advent Of Code, day 5: S(a|i)nt(a|erkl(a){2}s)

Xebia Background Header Wave

Every season of Advent of Code so far featured a story around Santa, with the Easter Bunny sometimes making a cameo appearance. On December 5 in The Netherlands, another legendary figure makes an appearance: Sinterklaas. Actually, the modern Santa Claus grew out of traditions surrounding the historical Saint Nicholas of Myra, on which the Dutch figure of Sinterklaas was also based. Anyway, especially on the evening of December 5, people in The Netherlands spend time with friends and family, write poems, wrap presents inside all kinds of handicrafts, and exchange gifts.

What’s the relevance of all this? Well, for some colleagues – and particularly those with children – it means less time being available to solve today‘s challenge. So instead, let’s take a look back one day first.

L(o){2}king(\s)back\2t\1\2day\s4

Asking a colleague on December 3 about his predictions for the puzzle of day 4, he replied:

Also a fearless regex wizard will bundle all their power into one expression to defeat the code of the ancient one. #justsayin #AdventOfCode #XebiaAoC

https://twitter.com/NakedN3rd/status/1201980373921607680

My reply was a variation on a famous quote by Jamie Zawinski:

Some people at #XebiaAoC, when confronted with an #AdventOfCode problem, think “I know, I’ll use regular expressions.” Now they have two problems.

https://twitter.com/jschulenklopper/status/1201982295508426756

My colleague only needed to remind me on the Advent of Code puzzle of December 7, 2016, which he solved with a mind-bogglingly regular expression: /([a-z])((?!\1)[a-z])(?=\1)(?=[a-z]*[\[\]](([a-z]*[\[\]]){2})*[a-z]*\2\1\2)/.

Being regularly and expressively pwnd by that, I decided to at least include a regular expression in my solution for day 4, and in the titles in this post.

By the way, in need for an online regular expression tester and debugger? I found RegExr and Regular Expressions 101 very convenient.

Day\s[^012346789]

Today’s challenge built upon the Intcode computer from day 2. Not a problem for colleagues participating from Xebia and XebiaLabs, although I saw a couple of them complaining about the length of today’s puzzle text, the requirement of careful reading, and the time necessary to complete the program. Let’s hope that tomorrow bring a shorter puzzle.

For me, I still need to start solving day 5. I think that I’ll listen to “Mercury” by Bloc Party while doing so – the planet is mentioned in the puzzle text. The reference to Mercury in the song is about the times when the planet appears to rotate in the opposite direction. In some cultures, this retrograde motion is thought to signify difficulties in communication… how very fitting for today’s text.

Questions?

Get in touch with us to learn more about the subject and related solutions

Explore related posts