Skip to content

Advent of Code Overview

This section demonstrates how to solve Advent of Code problems using Hardcaml. These examples show how hardware design principles can be applied to algorithmic challenges.

Advent of Code is an annual programming competition with daily puzzles throughout December. Each problem presents an algorithmic challenge are typically solved with software, but we’re solving them with hardware instead!

Solving AoC problems in Hardcaml demonstrates:

  • Sequential logic - State machines for processing streams of data
  • Arithmetic circuits - Adders, multipliers, comparators
  • Memory management - Registers and state tracking
  • Real-world applications - Beyond toy examples

Each AoC problem is implemented as a Hardcaml circuit with:

  • Input interface - Streams of data (digits, commands, etc.)
  • State registers - Track progress through the problem
  • Combinational logic - Process inputs and compute results
  • Output interface - Final answer or running totals
  1. Open the IDE
  2. Select an Advent of Code example from the dropdown
  3. Read the problem description in the circuit file
  4. Study the test harness to understand the input format
  5. Run the circuit to see the solution
  • Read the comments - Each circuit file has detailed problem descriptions
  • Check the tests - Test files show expected input/output formats
  • Watch waveforms - Visualize how state changes over time
  • Start simple - Begin with Day 1 to understand the pattern