Skip to content

About

Self-hosted web workbench for Advent of Code: puzzle, editor, runs and submissions in Prolog, Rust, JavaScript, PHP, Lua or Bash

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Advent of Code workbench

A small self-hosted web workbench for solving Advent of Code 2026 from the browser, in Prolog, Rust, JavaScript, PHP, Lua or Bash: read the puzzle, write the solution, run it on the examples and on your input, submit the answer, all in one page.

  • Days appear as they unlock (midnight US Eastern, 12 days), with a countdown to the next one. Each day comes with its puzzle text, your puzzle input (with your session cookie) and the example input and answer found in the puzzle.
  • Puzzle tab: the puzzle split into story (collapsed), rules, example and question. After part 1 is accepted, Continue to Part Two fetches part 2.
  • Editor: Monaco (the VS Code editor), one tab per solution file, autosave, errors and warnings shown as squiggles on the right line.
  • Inputs: example, input (your puzzle input) and any named ones you add, each with expected answers for part 1 and part 2.
  • Run: tick the inputs, pick part 1, 2 or both, ▶ Run (Ctrl+Enter). Each result shows the answer, pass/wrong against the expected value, timing, and what the solution printed.
  • Submit an answer to adventofcode.com from a result on your input. Every submission is recorded: an answer already rejected, or beyond a known "too high"/"too low", is never sent again; an accepted one becomes the expected value. Solved parts show as stars in the sidebar.

Quick start

git clone https://github.com/texthtml/adventofcode.git && cd adventofcode
docker compose up -d --build      # → http://127.0.0.1:8080/

Then set your adventofcode.com session cookie with 🔑 set AoC session (bottom left) to get your puzzle inputs and submit answers: it is the value of the session cookie of adventofcode.com (browser devtools → Application/Storage → Cookies).

Warning

The workbench runs whatever code is written in it, with no authentication of its own. By default it is only published on 127.0.0.1. Don't expose it without putting authentication in front of it (see Traefik).

Solutions

A day can have solutions in several languages, one file each. A new day has none: pick a language under the puzzle ("Start solving in: …"), add more with + next to the editor tabs. ▶ Run uses the solution that is open.

In every language, part1 / part2 receive the whole input as a string and return the answer. Anything printed is debug output, shown in the result; only the returned value is compared with the expected one.

language file definition notes
Prolog solution.pl part1(Input, Answer) :- … SWI-Prolog 10; helpers below
Rust solution.rs pub fn part1(input: &str) -> impl Display rustc -O, std only, compiled once per change; todo!() = not done yet
JavaScript solution.js export function part1(input) { … } Node 20; may be async; BigInt ok
PHP solution.php function part1(string $input) { … } PHP 8.4
Lua solution.lua function part1(input) … end Lua 5.4
Bash solution.sh part1() { …; } input on stdin, answer on stdout, debug to stderr (>&2)

New solutions start from templates/solution.*, with the puzzle questions added as comments above part1 / part2.

Prolog helpers, :- use_module(library(aoc)). (lib/aoc.pl): lines/2, blocks/2, ints/2 (signed), nats/2 (unsigned, "1-3" → [1,3]), words/2, split/3, grid/2, grid_cells/2, sum/2, product/2, transpose/2.

:- use_module(library(aoc)).

part1(Input, Answer) :-               % Input: the whole file as a string
    lines(Input, Lines),
    length(Lines, Answer).

Configuration

Settings go in a .env file next to compose.yaml (see .env.example):

variable default
AOC_UID / AOC_GID 1000 user/group the container runs as, so the files it writes are yours (id -u / id -g)
AOC_BIND / AOC_PORT 127.0.0.1 / 8080 where the UI is published
AOC_SESSION adventofcode.com session cookie (otherwise set it from the UI, stored in .aoc-session)
AOC_USER_AGENT AoC asks automated tools to include contact info in their User-Agent
AOC_DEFAULT_LANG create a solution in this language with each new day (prolog, rust, javascript, php, lua, bash)
AOC_DAYS 12 number of puzzles
AOC_NOW fake the current time (ISO date), for testing

Behind Traefik

compose.traefik.yaml serves the workbench through an existing Traefik (external traefik network, websecure entrypoint, letsencrypt resolver) with basic authentication, instead of publishing a port:

# .env
COMPOSE_FILE=compose.yaml:compose.traefik.yaml
AOC_HOST=aoc.example.com
AOC_BASICAUTH='you:$apr1$...'   # echo "you:$(openssl passwd -apr1 'password')"

Your data

Everything about the days lives in days/ (gitignored), as plain files:

days/NN/solution.<ext>       your solutions, one file per language
days/NN/inputs/<name>.txt    inputs (input.txt is your puzzle input)
days/NN/day.json             title, expected answers, submissions
days/NN/puzzle.html          the puzzle text

Advent of Code asks people not to redistribute the puzzle texts and inputs, so keep days/ out of public repositories.

Being nice to adventofcode.com

The server only talks to adventofcode.com when the UI is open: it fetches each puzzle and input once (when a day is created, or when you click a button), and submits answers only when you click Submit, never resending an answer it already knows is wrong.

Layout

compose.yaml, Dockerfile     SWI-Prolog image + Node, rustc, PHP, Lua
server/server.js             HTTP API + static files (Node, no dependencies)
server/runners/run.*         one runner per language: solution input part answer-file
templates/solution.*         starting point of a new solution, per language
lib/aoc.pl                   Prolog helpers
public/                      the UI

The repository is bind-mounted into the container, so changes to the server or the UI only need docker compose restart. Runs are killed after the timeout set in the UI (60 s by default); the container is capped at 4 GB of RAM.

About

Self-hosted web workbench for Advent of Code: puzzle, editor, runs and submissions in Prolog, Rust, JavaScript, PHP, Lua or Bash

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages