Advent of Code 2023: Clean Code Challenge

Competitions

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.

Advent of Code 2023

In December last year, Optiver proudly entered its third year as a sponsor of 

. 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.

Parallel with Optiver’s daily work

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.

The clean code challenge

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 clean code solution

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.
image-12.png

 

Want to solve puzzles for a living?

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.

Apply now page link

Optiver, a leading global market maker, announced a strong set of financial results for the year 2025, as the company marked its 40th anniversary.

Optiver is partnering with IIT Bombay to launch the IIT Bombay-Optiver AI Innovation Lab — a dedicated research facility that will support cutting-edge, interdisciplinary research in artificial intelligence.

Based in Washington, D.C., the Psaros Center is a leading academic initiative focused on advancing research, convening policymakers and financial industry leaders, and raising the quality of solutions-oriented discussion that impacts financial markets policy and practice.

Optiver’s new Sydney office at 275 Kent Street, is a purpose-built workplace designed to accelerate innovation, attract top talent, and strengthen the firm’s role as a leading market maker and liquidity provider in the Asia Pacific region.

Ranking among the world's top players for over a decade comes with the pressure to keep winning, and this year proved a challenging start for Anish.

Optiver and BMLL: A new approach to Level 3 market data

Principal Strategic Investments

Historical data at a high level of granularity isn’t easy to manage, and we found the datasets offered by vendors lacking.

Click below

Learn more about Optiver