skip to content
lav.ren / tinker / advent-of-code

Advent of Code Solver

Paste your puzzle input, pick the day, run the solver right in your browser. Pure functions, zero server.

Date
2026
Stack
ReactJavaScript
Part

2023 · Day 1: Trebuchet?! · puzzle on adventofcode.com ↗

How it works

Every solver is a pure function from string → number (raw puzzle input to numeric answer). They live in src/lib/aoc/solvers.js as plain JavaScript, no side effects, no DOM. The React component above calls solver.run(input) on click and displays the answer plus how long the computation took.

Right now Advent of Code 2023 Day 1 is wired up (both parts) — a classic warmup where you extract digits from each line and sum them. Part 2 is the fun one: spelled-out numbers like "eightwothree" count as overlapping matches, which trips up naive string.replace approaches.

Extending it

Adding a new day means:

  1. Write the solver as a pure function in solvers.js
  2. Register it as a DayPuzzle in the same file
  3. The UI picks it up automatically — the year/day selectors are derived from the registry

No code in this MDX file changes when a new day is added; this page is just a description wrapper around the island above.

Why this pattern

Advent of Code solvers are a perfect fit for React islands: the logic is pure (easy to test, easy to run anywhere), the UI is small (a form + a result), and the computation is client-side (no server needed). The whole experiment costs exactly zero bytes on every other page of this site — the React runtime and the solver JavaScript only load when you scroll this component into view.

If you’d like to contribute a solver (yours or mine improved), open a PR on GitHub.