Import LeetCode problems with usaco new <link> / usaco daily
Test and publish the site / test (push) Successful in 35s
Test and publish the site / publish (push) Successful in 29s

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]>
This commit is contained in:
2026-10-19 21:12:16 +01:00
co-authored by Claude Opus 5.5
parent 995b44a57a
commit e821df15f4
9 changed files with 813 additions and 9 deletions
+6 -3
View File
@@ -70,7 +70,7 @@ ${DIM}selection${RST}
${DIM}problem commands${RST} ${DIM}(name optional — omit it to use the selection; giving one switches to it)${RST}
$WITH_PROBLEM
${DIM}other${RST}
$NO_PROBLEM, new <name>
$NO_PROBLEM, new <name>, new <leetcode-url|daily>
help [<cmd>] this, or the dispatcher's usage line for <cmd>
!cmd run a shell command in the problem dir
q quit
@@ -135,8 +135,11 @@ while :; do
continue ;;
none|-) set_current ""; continue ;;
n|new)
[[ ${#args[@]} -ge 1 ]] || { echo "usage: n <name> [io-name] [--url <link>]" >&2; continue; }
if "$ROOT/usaco" new "${args[@]}"; then set_current "${args[0]}"; fi
[[ ${#args[@]} -ge 1 ]] || { echo "usage: n <name> [io-name] [--url <link>] | n <leetcode-url|daily>" >&2; continue; }
# new reports the name it created: a LeetCode link only becomes one after the fetch
created="$(mktemp)"
if USACO_CREATED="$created" "$ROOT/usaco" new "${args[@]}"; then set_current "$(<"$created")"; fi
rm -f "$created"
continue ;;
esac