LeeCo


NameLeeCo JSON
Version 0.0.1b0 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-05-24 10:27:22
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 (like [676](https://leetcode.com/problems/implement-magic-dictionary/)), 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": "https://files.pythonhosted.org/packages/6e/c0/ca4a0cfc7bc2af9999af0787f47cc8cee0ba07ef110c6ceb40acd0abab8d/leeco-0.0.1b0.tar.gz",
    "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 (like [676](https://leetcode.com/problems/implement-magic-dictionary/)), 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.1b0",
    "project_urls": {
        "Homepage": "https://github.com/JezaChen/LeeCo"
    },
    "split_keywords": [
        "leetcode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ec0ca4a0cfc7bc2af9999af0787f47cc8cee0ba07ef110c6ceb40acd0abab8d",
                "md5": "2c12fd05a549542a5111f1691d37425c",
                "sha256": "d1ce37477efd812887e8ae0af98b235c0f6eb679a47b90bd4305e72a917363ab"
            },
            "downloads": -1,
            "filename": "leeco-0.0.1b0.tar.gz",
            "has_sig": false,
            "md5_digest": "2c12fd05a549542a5111f1691d37425c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 9537,
            "upload_time": "2024-05-24T10:27:22",
            "upload_time_iso_8601": "2024-05-24T10:27:22.497213Z",
            "url": "https://files.pythonhosted.org/packages/6e/c0/ca4a0cfc7bc2af9999af0787f47cc8cee0ba07ef110c6ceb40acd0abab8d/leeco-0.0.1b0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-24 10:27:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JezaChen",
    "github_project": "LeeCo",
    "github_not_found": true,
    "lcname": "leeco"
}
        
Elapsed time: 4.13664s