LeeCo


NameLeeCo JSON
Version 0.0.1a1 PyPI version JSON
download
home_pagehttps://github.com/JezaChen/LeeCo
SummaryLeeCo: A utility for empowering the local debugging of LeetCode problems with testcases.
upload_time2024-04-29 07:06:04
maintainerNone
docs_urlNone
authorJianzhang Chen
requires_python<4,>=3.7
licenseMIT
keywords leetcode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LeeCo: A utility for empowering debugging LeetCode problems locally in Python

[![PyPI version](https://badge.fury.io/py/leeco.svg)](https://badge.fury.io/py/leeco)

## 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.

```bash
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.

```python

# <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.

```python
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, 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.

```python
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.
- [x] 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 `test` and `inject` function to the user.
- [x] Support the replacement of `ListNode` or `TreeNode` defined by the user.
- [ ] Unit tests.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JezaChen/LeeCo",
    "name": "LeeCo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.7",
    "maintainer_email": null,
    "keywords": "leetcode",
    "author": "Jianzhang Chen",
    "author_email": "jezachen@163.com",
    "download_url": null,
    "platform": null,
    "description": "# LeeCo: A utility for empowering debugging LeetCode problems locally in Python\r\n\r\n[![PyPI version](https://badge.fury.io/py/leeco.svg)](https://badge.fury.io/py/leeco)\r\n\r\n## Introduction\r\n\r\nFor some LeetCode problems related to Binary Tree, Linked List, etc.,\r\nit is always difficult to debug the code locally with testcases provided by LeetCode,\r\nsince the input and output format is customized\r\n(For example, the representation of a binary tree / linked list is a list of integers,\r\nand the input of design problems is sequences of operations and parameters.)\r\nand you may write a lot of test codes manually to debug the code locally.\r\n\r\nThis package provides a utility to help you debug the code locally with these testcases without\r\nstruggling with the input and output format.\r\n\r\n## Installation\r\n\r\nJust run the following command to install the package.\r\n\r\n```bash\r\npip install leeco\r\n```\r\n\r\n## Usage\r\n\r\nIn most cases, You just add the `__main__` block in your code without modifying the original solution code.\r\nAnd write the testcases in the `__main__` block as follows.\r\n\r\n```python\r\n\r\n# <Your solution code here>\r\n\r\nif __name__ == \"__main__\":\r\n    import leeco\r\n    leeco.test(\"\"\"\r\n<Your testcases here, same as the input format of LeetCode>\r\n    \"\"\")\r\n```\r\n\r\nIf you define more than one outer function (whose name is not started with `_`) in `Solution` class, \r\nyou should manually specify the main function (defined by LeetCode) to test.\r\n\r\n```python\r\nclass Solution:\r\n    def function1(self, ...):\r\n        # The outer function defined by you\r\n        pass\r\n\r\n    def mainPoint(self, ...):\r\n        # The main function defined by LeetCode\r\n        pass\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    import leeco\r\n\r\n    leeco.inject(Solution.mainPoint)\r\n    leeco.test(\"\"\"\r\n<Your testcases here, same as the input format of LeetCode>\r\n    \"\"\")\r\n```\r\n\r\nFor design problems, if you define more than one outer class (whose name is not started with `_`) in your code,\r\nyou should manually specify the main class (defined by LeetCode) to test.\r\n\r\n```python\r\nclass YourClass:\r\n    \"\"\" The class defined by you \"\"\"\r\n    \r\nclass MainClass:\r\n    \"\"\" The main class defined by LeetCode \"\"\"\r\n\r\nif __name__ == \"__main__\":\r\n    import leeco\r\n    leeco.inject(MainClass)\r\n    leeco.test(\"\"\"\r\n<Your testcases here, same as the input format of LeetCode>\r\n\"\"\")\r\n```\r\n\r\nAnd then debug the code, add breakpoints and do anything you want with your favorite IDE or text editor.\r\n\r\n## TODOs\r\n\r\n- [ ] When parse the input of list, support calling the parser of the element type.\r\n- [ ] Support the problems related to the probability.\r\n- [x] Support the timing of the function.\r\n- [ ] Support fetching the official testcases from LeetCode.\r\n- [ ] Support the recursive parsing of the input, e.g., List[List[int]].\r\n- [ ] Support the comparison of the output with the expected output.\r\n- [ ] Only expose the `test` and `inject` function to the user.\r\n- [x] Support the replacement of `ListNode` or `TreeNode` defined by the user.\r\n- [ ] Unit tests.\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LeeCo: A utility for empowering the local debugging of LeetCode problems with testcases.",
    "version": "0.0.1a1",
    "project_urls": {
        "Homepage": "https://github.com/JezaChen/LeeCo"
    },
    "split_keywords": [
        "leetcode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6978bc3dd745b66edd7def30a878468644d5fce8674f39949b2e2cb46dfe37b0",
                "md5": "96f210f4025f197bd4005c299e891408",
                "sha256": "4c9fdcb9d000c96324cc0b31692c06b91fe05084150996294c9ce100d6204200"
            },
            "downloads": -1,
            "filename": "LeeCo-0.0.1a1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "96f210f4025f197bd4005c299e891408",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.7",
            "size": 10726,
            "upload_time": "2024-04-29T07:06:04",
            "upload_time_iso_8601": "2024-04-29T07:06:04.440968Z",
            "url": "https://files.pythonhosted.org/packages/69/78/bc3dd745b66edd7def30a878468644d5fce8674f39949b2e2cb46dfe37b0/LeeCo-0.0.1a1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 07:06:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JezaChen",
    "github_project": "LeeCo",
    "github_not_found": true,
    "lcname": "leeco"
}
        
Elapsed time: 0.25433s