Skip to main content

Run LeetCode-style Python solutions against local TOML test cases.

Project description

Leet-Chaser

本地运行 leetcode solution 的命令行框架。

使用方法

STEP 1: 初始化题目目录

leet-chaser init two-sum
cd two-sum

命令会在当前目录创建一个题目文件夹:

two-sum/
├── solution.py
└── cases.toml

STEP 2: 编写 solution.py

from typing import List


class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        seen = {}
        for index, num in enumerate(nums):
            rest = target - num
            if rest in seen:
                return [seen[rest], index]
            seen[num] = index
        return []

STEP 3: 填写 cases.toml

entrypoint 是 solution 里的入口方法名。input 是传给入口方法的位置参数数组,output 是期望返回值。

entrypoint = "twoSum"

[[cases]]
input = [[2, 7, 11, 15], 9]
output = [0, 1]

[[cases]]
input = [[3, 2, 4], 6]
output = [1, 2]

[[cases]]
input = [[3, 3], 6]
output = [0, 1]

STEP 4: 运行验证

leet-chaser run .

标准示例

仓库内置了 LeetCode 1. Two Sum 的标准示例:

uv run leet-chaser run examples/two-sum

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leet_chaser-0.1.1.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leet_chaser-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file leet_chaser-0.1.1.tar.gz.

File metadata

  • Download URL: leet_chaser-0.1.1.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for leet_chaser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cb10a3568d3486261d733413e18bba5eaedec2537a306090d2d9d9f803aee78c
MD5 aed8be07f1e389c6c62482d9301b768d
BLAKE2b-256 ef70bf384e8532dc29d4e7ac3e7d57f6e311c23c9f7e774341bd917ce2a2d000

See more details on using hashes here.

Provenance

The following attestation bundles were made for leet_chaser-0.1.1.tar.gz:

Publisher: publish.yml on gawainx/leet-chaser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file leet_chaser-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: leet_chaser-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for leet_chaser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 74be183c5ea3fbc5e39d812bb1e977493c6fe7d49c217fa4b1dedf3ddd524f25
MD5 5f08defc1bb2b525e7b2c35aecb69ae1
BLAKE2b-256 4797085c5cb0d8d4737e787a1ee21e66c5a4db5fd4a66a21bfbc75cd41265b2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for leet_chaser-0.1.1-py3-none-any.whl:

Publisher: publish.yml on gawainx/leet-chaser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page