Back
Competition  · 

Advent of Code 2023: Clean Code Challenge

In December last year, Optiver proudly entered its third year as a sponsor of Advent of Code. This annual event, structured like an advent calendar, offers tech enthusiasts from around the world the chance to test and showcase their creative programming skills with a new festive-themed puzzle each day. Our sponsorship reinforces our commitment to fostering technical innovation and a culture of continuous learning.

This year, we took our participation one step further by hosting an internal Advent of Code challenge. We invited our employees to apply their problem-solving skills and compete on Optiver’s leaderboard, bringing a friendly festive competition to the workplace.

In this blog post, we’ll explore how the challenges of the Advent of Code mirror those we encounter at Optiver. We’ll also highlight how one of our engineers leveraged their skills to solve a challenge using the principles of clean code, showcasing a key aspect of our industry.

The daily challenges of Advent of Code represent a direct parallel to our everyday work at Optiver. Each puzzle demands not just coding skills, but a creative, adaptable problem-solving mentality – much like our approach to our trading systems.

In our core operations, engineers at Optiver must not only be proficient in programming languages but also have a deep understanding of the trading challenges at hand. Their role involves transforming these insights into effective software solutions. Similarly, Advent of Code presents algorithmic challenges revolving around processing complicated datasets in ways that aren’t immediately obvious. The same kind of problem solving applies to creating software to trade on financial markets.

This focus on providing a platform for people to learn and understand more about the world of computer science, resonates deeply with Optiver’s emphasis on continuous learning and development.

This year’s Advent of Code also brought into focus a crucial element in our industry – the art of clean code. Given the critical nature of executing trades at extremely low latencies, clean code is essential in minimising processing time and reducing latency, a necessity in a field where milliseconds can equate to significant financial implications. Moreover, clean code is synonymous with robust and scalable systems, vital for the reliability required in our trading operations.

In a special challenge at our Amsterdam office, engineers were tasked with solving the Day 9 puzzle of Advent of Code, but with a twist: their solutions had to be not just effective, but also clean, readable, and well-structured. This challenge allowed participants to demonstrate their ability to apply the skills they use in their day-to-day work to produce code that was technically proficient and clean.

The Day 9 puzzle in Advent of Code presented a unique challenge: analysing sensor data to construct a pyramid-shaped data structure for predicting the next sequence value. The winning solution, crafted by Daniel O’Connor, stood out for its exceptional clarity and conciseness. This submission not only solved the puzzle effectively but did so with a code structure that exemplified clean coding principles.

Let’s delve into this solution:

  • Problem overview: The puzzle required analysing a sensor output and building a pyramid shaped data structure to predict the next value in the sequence.
  • Solution approach: Implementing his solution in Rust, Daniel introduced an innovative, easily reversible method by incorporating a single flag. This approach not only solved the puzzle effectively but also cleanly.
  • Code snippets and explanation: Daniel described his process, saying, ‘For Day 9, the task involved parsing each line and using a recursive function, next_in_sequence, to determine the subsequent values, ultimately leading to the sum as the final output. Choosing recursion over a loop was a deliberate decision to align closely with the problem’s structure.’
    He also highlighted the significance of clean code in his solution, incorporating comments for clarity, test cases for reliability, and specific error messages for invalid inputs, like ‘Error solving part A: when parsing “26f”, invalid digit found in string.’ These elements are crucial for maintaining, testing, and debugging code, exemplifying key practices of clean coding.

Advent of Code is not just a series of puzzles; it’s a celebration of the skills that drive the tech community forward. At Optiver, we’re proud to be part of this community, continually pushing the boundaries of what’s possible in the world of technology and trading. We remain committed to fostering an environment where technical skill, creativity, and a passion for problem-solving can thrive.

Do you share our passion for technology, problem-solving, and continuous learning? If so, we would love to hear from you. Check out our open roles.

CompetitionExperienced
Insights

Related Articles

  • Competition, News

    Ready Trader Go: An interview with 2021 finalist Guyon van Rooij

    Ready Trader Go, Optiver’s global coding competition, presents an excellent way for students to test their coding strength and dive headfirst into the world of algorithmic trading. On top of fine-tuning trading algorithms for Optiver’s simulated market exchange, RTG also provides a unique opportunity for students to join a competition that requires no previous knowledge of coding or trading in general – and provides a chance to win a monetary prize.

    Learn more
    EMEA, Global
  • Competition, Life at Optiver

    From Ready Trader One to Trader

    We spoke to the 2020 winner of Ready Trader One – Jason Ruan about his experience of the challenge last year and what it has been like starting as a Graduate Trader at Optiver. What did you learn from RT1? My biggest take away is definitely understanding exactly how market making works in the financial […]

    Learn more