{ "info": { "author": "Chengyu Tang", "author_email": "chyutang@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "\n# LeetCode Toolkit (lctk)\nGitHub page: https://github.com/chengyutang/lctk\n\n**lctk** is tool for creating LeetCode test cases for the ease of local testing.\n\n## 1. Introduction\n[LeetCode](https://leetcode.com) is a website where people can improve their coding skills and get prepared for techical interviews by solving coding problems and discussing with other people. Users can use the online judge (OJ) to run and test their codes within the brower. But the OJ could sometimes be slow, due to network limit or server overflow, which is not very convenient and efficient, especially when submitting frequently. Therefore, some users prefer to write and test their codes locally for a more convenient test (and a better looking submission history :p).\n\nBut for some of the problems, where the inputs are customised data structures, such as linked list, binary tree and graph, it's difficult to come up with test cases locally, while LeetCode uses built-in data structures to represent them, which makes it much easier to create test cases. For example, linked lists and binary trees are represented by arrays, and graphs are represented by dictionaries. \n\nThis tool helps users with creating linked list, binary tree, and graph locally from array or dictionary, for the ease of local testing.\n\n## 2. Installation\nIf pip is installed, type the following command in the terminal to install this package\n```sh\npip install lctk\n```\nTo install pip, refer [here](https://pip.pypa.io/en/stable/installing/).\n\n## 3. Usage\nFirst import this package simply using\n```python\nimport lctk\n```\n\n### 3.1 Linked List\n**API:**\n```python\nlctk.linkedList(arr, cyclePos = -1)\n```\nLinked list is represented by array in LeetCode's console. To create the equivalent linked list from an array, use the following command\n```python\nhead = lctk.linkedList(arr)\n```\n`head` would be the head node (a `ListNode` object) of the linked list represented by the input array `arr`.\n\nAdditionally, if you want to construct a linked list that has a cycle, just simply specify the position that the cycle begins (0-indexed). For example:\n```python\nhead = lctk.linkedList(arr, 2)\n```\nTo print the values in a linked list, use the `linkedList2Arr` function, which also works with linked list that has a cycle.\n```python\narr = lctk.linkedList2Arr(linkedList)\nprint(arr)\n```\nPS: the definition of ListNode:\n```python\nclass ListNode:\n\tdef __init__(self, x):\n\t\tself.val = x\n\t\tself.next = None\n```\n\n### 3.2 Binary Tree\nSimilar with linked list, a binary tree is also represented by an array in LeetCode's console, and the order is a layer-wise, left-to-right travesal of the tree.\n\nGiven an input array `arr` that represents a binary tree, the following command\n```python\nroot = lctk.binaryTree(arr)\n ```\nwhere `root\t` would be the root node (a `TreeNode` object) of the equivalent binary tree.\n\nYou can also do the opposite, getting the array representation of a binary tree given a TreeNode `root` using\n```python\narr = lctk.binaryTree2Arr(root)\n```\nExample:\n```python\n>>> inArr = [1, 2, 3, 4, None, 5, None, 6, None, None, None, 7\n>>> root = lctk.binaryTree(inArr)\n>>> outArr = lctk.binaryTree2Arr(root)\n>>> inArr == outArr\nTrue\n```\nThe definition of TreeNode:\n```python\nclass TreeNode:\n\tdef __init__(self, x):\n\t\tself.val = x\n\t\tself.left = None\n\t\tself.right = None\n```\n\n### 3.3 Graph (Directed and Undirected)\nIn LeetCode, a graph is typically represented by a dictionary, just like that in [Leetcode #133: Clone Graph](https://leetcode.com/problems/clone-graph/).\n```python\nroot = lctk.graph(inDict)\n```\n`root` would be the root node (a `GraphNode` object) of the graph represented by the input dictionary `inDict`.\nThe definition of graph node:\n\nAs always, you can also get the dictionary representation given a GraphNode `root` using\n```python\noutDict = lctk.graph2Dict(root)\n```\nExample:\n```python\n>>> inDict = {\"$id\":\"1\",\"neighbors\":[{\"$id\":\"2\",\"neighbors\":[{\"$ref\":\"1\"},{\"$id\":\"3\",\"neighbors\":[{\"$ref\":\"2\"},{\"$id\":\"4\",\"neighbors\":[{\"$ref\":\"3\"},{\"$ref\":\"1\"}],\"val\":4}],\"val\":3}],\"val\":2},{\"$ref\":\"4\"}],\"val\":1}\n>>> root = lctk.graph(inDict)\n>>> outDict = lctk.graph2Dict(root)\n>>> inDict == outDict\nTrue\n```\nThe definition of GraphNode:\n```python\nclass GraphNode:\n\tdef __init__(self, x):\n\t\tself.val = x\n\t\tself.neighbors = []\n```\n## 4. Conclusion\nIf there were any error or suggestions, please let me know through the GitHub repository page shown above.\n\nHappy LeetCoding!\n\n## Version History\n0.0.1: Initial version.\n\n0.0.2: Added supported for linked list with cycle.\n\n0.0.3: Fixed bugs.\n\n0.0.4: Corrected the wrong usage description of linkedList API.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chengyutang/lctk", "keywords": "LeetCode", "license": "", "maintainer": "", "maintainer_email": "", "name": "lctk", "package_url": "https://pypi.org/project/lctk/", "platform": "", "project_url": "https://pypi.org/project/lctk/", "project_urls": { "Homepage": "https://github.com/chengyutang/lctk" }, "release_url": "https://pypi.org/project/lctk/0.0.4/", "requires_dist": null, "requires_python": "", "summary": "A tool to create linked list, binary tree and graph from array or dictionary for the ease of local test", "version": "0.0.4" }, "last_serial": 5997346, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6762ff6d6e6aa7a370969fc78c1637da", "sha256": "b096b021394c8a511991b33b01f3d992e4ec5fa27bf9f872421b42ff189c705c" }, "downloads": -1, "filename": "lctk-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6762ff6d6e6aa7a370969fc78c1637da", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4683, "upload_time": "2019-10-04T03:53:15", "url": "https://files.pythonhosted.org/packages/d4/32/fade8f849353ac30784d530633d308ed9ecd141c96ccea47503611369fb2/lctk-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a296a22486d97b9d648133d23842a79", "sha256": "0b0f440dfa57b5b1286376e1ec02055fa35d18e66a55b62af494161b7ee0bf94" }, "downloads": -1, "filename": "lctk-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6a296a22486d97b9d648133d23842a79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3721, "upload_time": "2019-10-04T03:53:18", "url": "https://files.pythonhosted.org/packages/92/36/8b81694cf78f1cdabf8b0066ddb412c5abee9dd51d6eb5ec3718811ee29d/lctk-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "3aaaf3255e3b0bb92b6d0b90866fad59", "sha256": "d9c2910a844f339dc4e7fc86e6ab0c0c63e5f31d34ac3afefdd860f5381ff192" }, "downloads": -1, "filename": "lctk-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "3aaaf3255e3b0bb92b6d0b90866fad59", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5094, "upload_time": "2019-10-04T20:58:15", "url": "https://files.pythonhosted.org/packages/8e/74/f71853efd2570552b6ea3f85456fa6b131e5465dbda0a92cf8591c0566e5/lctk-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d085415ef266a50d9f0df21e4393422e", "sha256": "0e2f5ac15227fbdd224f0f3021c220bda6d8b3c967f4c9ed5f9861dad742c580" }, "downloads": -1, "filename": "lctk-0.0.2.tar.gz", "has_sig": false, "md5_digest": "d085415ef266a50d9f0df21e4393422e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4247, "upload_time": "2019-10-04T20:58:16", "url": "https://files.pythonhosted.org/packages/d8/95/99f39b4d0f458af7062a4e7915cb20205671182f79de250faa2d44110c67/lctk-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "4b53abea295fd01e6054fea783eca4bf", "sha256": "573c276ded5d2f50e7061aaa65fda3ea159f3e5f8cbc095b237237e8e63bfb46" }, "downloads": -1, "filename": "lctk-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "4b53abea295fd01e6054fea783eca4bf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5074, "upload_time": "2019-10-04T21:11:48", "url": "https://files.pythonhosted.org/packages/d9/18/1e72e85a7a9c3fe72c028833c20a3a0d1c14aadc1bff4723f2a8e2fe6cfa/lctk-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "06a0deed2e73dff53c3f1b9983213c40", "sha256": "efaa6e41a662ef3395bc2df2d85e8afb108e897abaa810738cea5b77f26d4b27" }, "downloads": -1, "filename": "lctk-0.0.3.tar.gz", "has_sig": false, "md5_digest": "06a0deed2e73dff53c3f1b9983213c40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4234, "upload_time": "2019-10-04T21:11:50", "url": "https://files.pythonhosted.org/packages/de/61/24c31228f2a1e91ca8f2011d23b359d0e5e578cc7089d116f61ec72e2dc6/lctk-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "83621590bf950ebe71bc0df21e65b6ae", "sha256": "cc423c890a68b722a450493d79534097f3c4e781f465b9da98a132c6f4b38af6" }, "downloads": -1, "filename": "lctk-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "83621590bf950ebe71bc0df21e65b6ae", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5116, "upload_time": "2019-10-18T20:15:19", "url": "https://files.pythonhosted.org/packages/84/fa/9f277fc9acba1fd8df93dab8d7da83283ad95facf0337d7220324dc97d41/lctk-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5307172cc51e6a9f209993f4c476d473", "sha256": "1c6c93788aadb564aaefa5c4edb727fa7a5cc25992e86036737bcc41e6bbf8b3" }, "downloads": -1, "filename": "lctk-0.0.4.tar.gz", "has_sig": false, "md5_digest": "5307172cc51e6a9f209993f4c476d473", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4287, "upload_time": "2019-10-18T20:15:21", "url": "https://files.pythonhosted.org/packages/f6/6a/150a20328d71f60d28d5ecc2507c8ab3b0e71c84e7519d10b9548c36f0a7/lctk-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "83621590bf950ebe71bc0df21e65b6ae", "sha256": "cc423c890a68b722a450493d79534097f3c4e781f465b9da98a132c6f4b38af6" }, "downloads": -1, "filename": "lctk-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "83621590bf950ebe71bc0df21e65b6ae", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5116, "upload_time": "2019-10-18T20:15:19", "url": "https://files.pythonhosted.org/packages/84/fa/9f277fc9acba1fd8df93dab8d7da83283ad95facf0337d7220324dc97d41/lctk-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5307172cc51e6a9f209993f4c476d473", "sha256": "1c6c93788aadb564aaefa5c4edb727fa7a5cc25992e86036737bcc41e6bbf8b3" }, "downloads": -1, "filename": "lctk-0.0.4.tar.gz", "has_sig": false, "md5_digest": "5307172cc51e6a9f209993f4c476d473", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4287, "upload_time": "2019-10-18T20:15:21", "url": "https://files.pythonhosted.org/packages/f6/6a/150a20328d71f60d28d5ecc2507c8ab3b0e71c84e7519d10b9548c36f0a7/lctk-0.0.4.tar.gz" } ] }