Skip to main content

submit_puzzle_answer()

Submit an answer for a specific puzzle part.

Usage

Source

submit_puzzle_answer(
    year,
    day,
    part,
    answer,
    session=None,
)

Local guess history can resolve duplicate answers, numeric bounds, completed parts, and active cooldowns before a network request.

Parameters

year: int

The event year (e.g., 2024).

day: int

The puzzle day number.

part: int

The puzzle part (1 or 2).

answer: int | str

The answer to submit. Strings are stripped of surrounding whitespace.

session: str | None = None
An Advent of Code session token. If omitted, AOC_SESSION is used.

Returns

SubmissionResult
A structured result describing the outcome of the submission.

Raises

MissingSessionTokenError

If no session token is supplied or configured.

PuzzleLockedError

If the puzzle has yet to unlock in America/New_York.

SubmissionError

If the request fails or elf cannot prepare or lock the guess cache.

ElfError

If elf cannot read the guess history.

ValueError
If the date or part is invalid, or the answer is blank.

Notes

Each call makes at most one submission. For a cooldown result, use retry_at to decide when to try again.