Skip to main content

Getting started with Elf

Elf helps you fetch Advent of Code inputs, work through puzzles in Positron, submit answers, and check your progress from Python or the terminal.

Install and connect

Elf requires Python 3.11 or later. From your puzzle project, install it as a project dependency. If you are starting with an empty folder, run uv init there first.

uv add elf
uv run elf --help

The examples on this page use uv run to select the project environment. If you install with python -m pip install elf in an active environment or use uv tool install elf for CLI-only use, run elf directly.

Sign in to Advent of Code and copy the session cookie for adventofcode.com from your browser’s storage inspector. Set it in the environment used by Elf. Set a contact email so Advent of Code can identify automated requests.

export AOC_SESSION="your-session-cookie"
export AOC_USER_AGENT="you@example.com"
uv run elf doctor

In PowerShell, use $env:AOC_SESSION = "your-session-cookie" and $env:AOC_USER_AGENT = "you@example.com". Launch Positron from a configured environment or set the variables in the environment used by its Python session. Keep the cookie out of scripts and version control. elf doctor checks local configuration without contacting Advent of Code.

Solve a puzzle in Positron

uv run elf new 2025 1

This creates 2025/day01.py. Use --output path/to/day01.py for a custom location. Elf refuses to overwrite an existing file.

  1. Open your puzzle folder in Positron and select the Python interpreter where you installed Elf. With uv, this is the project’s .venv interpreter. Open the generated file. In Setup, choose PART = 1 or PART = 2. To work offline with an example, paste it into sample in Load Input and set USE_SAMPLE = True.
  2. Run Setup through the selected part. Edit data = lines in Parse Input as needed, then replace the answer placeholder in the selected part. Inspect raw, lines, data, and your intermediate variables in the Variables pane.
  3. For a real answer, set USE_SAMPLE = False and rerun Setup through the selected part. Inspect the result, set SUBMIT = True in the console, and run Submit. The flag resets after each attempt and when you reload, parse, or recompute.

Rerun from Setup after changing the puzzle, input mode, or Advent of Code account. Loading or parsing input clears both answers. Submission requires a computed answer for the selected part and real input for the current year and day. If the session cookie changes after input is loaded, rerun from Load Input through the selected part before submitting.

You can also run uv run python 2025/day01.py in the configured environment. It prints the selected answer once implemented. Submission is off by default.

Use Elf from Python

from elf import get_puzzle_input, get_user_status

lines = get_puzzle_input(2025, 1).splitlines()
status = get_user_status(2025)
print(status.total_stars)

The same session configuration applies in Python. See Reference for submit_puzzle_answer, get_private_leaderboard, and the available result models and output formats.

See Command-line workflows for common commands, output formats, and cache behavior.

AI / Agents

Skills
llms.txt
llms-full.txt

Developers

cak

Author

Community

Full license MIT

Meta

Requires: Python >=3.11
Package Info