This release is a pre-release and may not be stable for production use.
LeeCo: A utility for empowering debugging LeetCode problems locally in Python
Introduction
For some LeetCode problems related to Binary Tree, Linked List, etc., it is always difficult to debug the code locally with testcases provided by LeetCode, since the input and output format is customized (For example, the representation of a binary tree / linked list is a list of integers, and the input of design problems is sequences of operations and parameters.) and you may write a lot of test codes manually to debug the code locally.
This package provides a utility to help you debug the code locally with these testcases without struggling with the input and output format.
Installation
Just run the following command to install the package.
pip install leeco
Usage
In most cases, You just add the __main__ block in your code without modifying the original solution code.
And write the testcases in the __main__ block as follows.
# <Your solution code here>
if __name__ == "__main__":
import leeco
leeco.test("""
<Your testcases here, same as the input format of LeetCode>
""")
If you define more than one outer function (whose name is not started with _) in Solution class,
you should manually specify the main function (defined by LeetCode) to test.
class Solution:
def function1(self, ...):
# The outer function defined by you
pass
def mainPoint(self, ...):
# The main function defined by LeetCode
pass
if __name__ == "__main__":
import leeco
leeco.inject(Solution.mainPoint)
leeco.test("""
<Your testcases here, same as the input format of LeetCode>
""")
For design problems (like 676), if you define more than one outer class (whose name is not started with _) in your code,
you should manually specify the main class (defined by LeetCode) to test.
class YourClass:
""" The class defined by you """
class MainClass:
""" The main class defined by LeetCode """
if __name__ == "__main__":
import leeco
leeco.inject(MainClass)
leeco.test("""
<Your testcases here, same as the input format of LeetCode>
""")
And then debug the code, add breakpoints and do anything you want with your favorite IDE or text editor.
TODOs
- When parse the input of list, support calling the parser of the element type.
- Support the problems related to the probability.
- Support the timing of the function.
- Support fetching the official testcases from LeetCode.
- Support the recursive parsing of the input, e.g., List[List[int]].
- Support the comparison of the output with the expected output.
- Only expose the
testandinjectfunction to the user. - Support the replacement of
ListNodeorTreeNodedefined by the user. - Unit tests.
- Print or store intermediate results for
lru_cache
Metadata
Release files for LeeCo 0.0.1rc0
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 | Actions |
|---|---|---|---|---|
| leeco-0.0.1rc0.tar.gz | 10.1 kB | Without provenance | Details for leeco-0.0.1rc0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| leeco-0.0.1rc0-py3-none-any.whl | Python 3 | none | any | Details for leeco-0.0.1rc0-py3-none-any.whl |
Total release size: 22.8 kB
Release files / leeco-0.0.1rc0.tar.gz
| Download URL | leeco-0.0.1rc0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03c3110a84277a1897628cf33f2536354653ec2a81fec82515fc056b8210b11b
|
|
BLAKE2b-256 checksum How to use checksums |
5d8f7a2a4683375943b0327ff4a2d8f72de744c38ac17c25c2a4642dcc2450d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / leeco-0.0.1rc0-py3-none-any.whl
| Download URL | leeco-0.0.1rc0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
773daec6a7a739b21dea3bd4959efca9eb2cd486a30a5b95337e8b46c4506bc7
|
|
BLAKE2b-256 checksum How to use checksums |
3acc758547a952d8d31e4e3464c6fa4a520979d95aa60ab31c7e0790c342b5c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for LeeCo 0.0.1rc0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.