leeth
local leetcode harness to maximise efficiency
- Problem scaffolding
- Run & edit most recently modified file
- Custom validation functions
- Supports LeetCode design questions
- Paste LeetCode inputs as-is:
[1, 2, 3]becomes aListNodeorTreeNodewhen the type hint asks for one - LeetCode's default imports, plus
icandtodo() - Colored PASS/FAIL output with diffs and timings
Install
Requires Python 3.14+.
uv tool install leeth # or: pipx install leeth
This installs the leet command. Solution files from leeth import *, so run them
with leet run, or with a Python that has leeth installed.
Where problems live
leet uses the first of:
$LEET_DIR, if set (e.g.export LEET_DIR=~/leetcode/problems)- the nearest
problems/directory in or above the current directory ./problems, created byleet new
Development
uv sync && source .venv/bin/activate
Workflow
leet new 1 two sum # -> problems/0001_two_sum.py
leet new https://leetcode.com/problems/two-sum/
leet new 146 lru cache -d # design problem
leet e # edit the last-edited problem
leet # run it
leet run 1 # run by number or part of the name
Solution file
from leeth import *
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
seen = {}
for i, n in enumerate(nums):
if target - n in seen:
return [seen[target - n], i]
seen[n] = i
tests = [
test([2, 7, 11, 15], 9, expected=[0, 1]),
test(nums=[3, 3], target=6, expected=[1, 0]),
test([3, 2, 4], 6, expected=[2, 1], any_order=True),
test([1, 2], 3), # no expected: just print
]
if __name__ == "__main__":
run()
$ leet
Solution.twoSum (4 cases)
PASS #1 nums=[2, 7, 11, 15], target=9 0.01 ms
FAIL #2 nums=[3, 3], target=6 0.00 ms
expected: [1, 0]
got: [0, 1]
PASS #3 nums=[3, 2, 4], target=6 0.00 ms
OUT #4 nums=[1, 2], target=3 0.00 ms
got: [0, 1]
2/3 passed (0.02 ms total)
More test options
# several valid answers / mutated input: check gets the result (+ args after the call)
test([3, 2, 2, 3], 3, check=lambda k, nums, val: sorted(nums[:k]) == [2, 2])
# `-> None` methods: the first argument is compared to expected
test([1, 2, 3], expected=[3, 2, 1])
# pick a method other than the first one
run(method="twoSumSorted")
Design problems
tests = [
test(["LRUCache", "put", "get"], [[2], [1, 1], [1]], expected=[None, None, 1]),
]
if __name__ == "__main__":
run_design()
Metadata
Release files for leeth 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| leeth-0.1.0.tar.gz | 10.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leeth-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.2 kB
Release files / leeth-0.1.0.tar.gz
| Download URL | leeth-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a24a37c9097ad4913b5190f4adc8149e6cf7a9d34e7afa48f508aed147593d22
|
|
BLAKE2b-256 checksum How to use checksums |
8bfbc50938aecef3ae454ccb0382bd497e216a3a0451e0a9a05af83c6c90c7e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / leeth-0.1.0-py3-none-any.whl
| Download URL | leeth-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6e24f9d72476b0bcb3ed4eb1f909f141da7d9657fd3ca573cc234fdf92a5464
|
|
BLAKE2b-256 checksum How to use checksums |
536cf19ea4ea064e8f9a769b4efe5c86ddfcbe9361009790d0e32c7e902f41f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for leeth 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.