/usaco/concepts is a library of techniques Claude explained: the admin
asks by topic ("help explain fenwick trees") or pastes code they could
not follow, and gets an intuitive explanation with SVG diagrams plus a
C++ snippet in contest style. Given code, the walkthrough traces that
code and the snippet is a general version of it. Anyone can read the
library; generating, rewriting and deleting are admin-only.
Each concept is committed as concepts/<slug>/: concept.md (tags in a
header comment, then a # title), snippet.cpp (first line
"// concept: <slug>") and request.md (the question, for rewrites). The
slug is Claude's to pick, so a new concept's job is keyed by an id and
returns {slug} as its result; a taken slug gets -2, -3... rather than
overwriting. Rewriting starts from the saved question and version plus
a note on what to change. The index reads concepts into Index.Concepts,
with their date from git.
internal/concept shares explain's math and diagram rules, now split out
as explain.MathRules and explain.DiagramRules; the explain prompt is
byte-for-byte unchanged. Code fences in explanations are highlighted
with the same highlight.js setup as CodeBlock (web/src/highlight.js).
`usaco snippet` lists concepts, prints one's snippet, or pastes it into
a solution above main (or class Solution), keeping a .bak and refusing
a concept the file already has. In interactive mode it pastes into the
selection.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the stashed Rust work, merged onto the current CLI. A
problem's language is whichever source it has (main.cpp or main.rs);
'usaco lang' sets the default for new problems (.lang, or $USACO_LANG),
and 'new --rust/--cpp' picks per problem. template.rs is a paste-ready
Rust template whose stdio() uses <io>.in/.out when present and
stdin/stdout otherwise.
run/test now feed <io>.in on stdin and capture stdout when the program
doesn't write <io>.out itself, so Codeforces-style solutions work too.
'reset <name> rust|cpp' switches a problem's language (template is
still an alias), and --debug builds Rust with overflow checks and debug
assertions. 'usaco lint' runs clippy through a generated, gitignored
Cargo.toml that also gives rust-analyzer a project; done/skip/undo
keep it in step. LeetCode imports stay C++.
Also: done stages solved/ and solving/ separately, so a problem that
was never committed from solving/ still gets its "Solve" commit, and
the site lists main.rs ahead of other files like it does main.cpp.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
usaco new <leetcode-link> (alias: from) and usaco daily fetch a problem
from LeetCode's GraphQL API and write problem.md, main.cpp (template
header + LeetCode's C++ starter), a generated driver.h that runs the
solution on LeetCode-format input, and the examples as tests with the
expected outputs from the statement. leetcode.h holds ListNode/TreeNode
and the parse/print helpers; everything local sits behind #ifdef LOCAL
so main.cpp stays submittable.
reset re-fetches the starter code for LeetCode problems, the REPL's new
selects the imported problem, and usaco.zsh turns off globbing so a
pasted ?envType=... link works unquoted.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
When stuck, the admin can ask Claude for an intuitive explanation of a
problem. It is committed as explain.md and shown as folded sections, so
the reader opens only as much as they need: the key observation, hints
that get stronger, the approach, a walkthrough with an SVG diagram per
step, complexity, pitfalls and a pseudocode sketch.
- internal/claude: streamed call with a JSON-schema reply, high effort,
the server-side refusal fallback, fixed error messages and logged
token usage. CLAUDE_API_KEY and CLAUDE_MODEL (default claude-opus-5-5);
without a key only this feature is off.
- internal/explain: the prompt, the schema, rendering to markdown, and
a per-problem job tracker. The request starts a job and the page polls,
since a call outlasts nginx's 120s timeout.
- internal/statement: fetches statements from LeetCode's GraphQL API and
USACO's problem pages. Others (Codeforces is behind Cloudflare) are
pasted.
- problem.md holds the statement, editable from the meta editor and
shown only to the admin. Diagrams are sanitized with DOMPurify.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
/usaco/cli summarises the ./usaco commands, setup, a typical session and
interactive mode, linked from the header. It's a hand-written copy of the
README (the Docker build context is site/, so it can't import it).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- done/skip/undo accept unique prefixes like every other command
- builds define LOCAL (-I repo root): the template includes debugging.h
and enables DBG/printV only locally, so main.cpp is submittable as-is
- run/build/test --debug (or USACO_DEBUG=1): ASan/UBSan + _GLIBCXX_DEBUG
- list/stats date problems by git history, not mtimes reset by checkouts
- template/tpl is now an alias of reset (which gains -y); fixes template
dropping the STDIO line
- run shows <io>.out via detect_io instead of the first *.out
- debugging.h: size_t loop indices (no -Wsign-compare noise)
- zsh completion for i/cat/copy; README covers test, io, reset, --debug
- ignore a.out
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The website commits too, so `usaco sync` pulls its edits before pushing.
tests/*.out were swallowed by the *.out rule; they are expected outputs
the site shows, so re-include them.
Co-Authored-By: Claude Opus 5.5 <[email protected]>