{"id":19867292,"url":"https://github.com/huzecong/leetcode-contest-helper","last_synced_at":"2025-05-02T06:30:56.806Z","repository":{"id":44333720,"uuid":"224055012","full_name":"huzecong/leetcode-contest-helper","owner":"huzecong","description":"A LeetCode contest utility for the dead serious. Generate template code for local testing.","archived":false,"fork":false,"pushed_at":"2023-12-23T07:00:43.000Z","size":44,"stargazers_count":27,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T23:13:54.030Z","etag":null,"topics":["leetcode","leetcode-contests","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huzecong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-25T22:39:30.000Z","updated_at":"2024-12-08T07:42:45.000Z","dependencies_parsed_at":"2024-11-12T15:33:37.578Z","dependency_job_id":"1f1299bd-b609-412a-a8c8-70b945e9aa20","html_url":"https://github.com/huzecong/leetcode-contest-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huzecong%2Fleetcode-contest-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huzecong%2Fleetcode-contest-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huzecong%2Fleetcode-contest-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huzecong%2Fleetcode-contest-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huzecong","download_url":"https://codeload.github.com/huzecong/leetcode-contest-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251998207,"owners_count":21677947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leetcode","leetcode-contests","python3"],"created_at":"2024-11-12T15:28:57.191Z","updated_at":"2025-05-02T06:30:56.560Z","avatar_url":"https://github.com/huzecong.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LeetCode Contest Helper\n\n\u003e A LeetCode contest utility for the dead serious.\n\n\n## A Bit of Background...\n\nIf you've taken part in [LeetCode contests](https://leetcode.com/contest/), you might have been annoyed by their\nridiculous sample input formats. I know I have. The format of LeetCode format is similar to that of TopCoder -- you're\nrequired to implement a specific function in a \"Solution\" class, and input is provided as arguments, while output is the\nreturn value. While this alleviates the burden of hand-written I/O, it makes local testing especially difficult.\n\nTopCoder contestants might be familiar with Arena plug-ins like\n[TZTester](https://community.topcoder.com/contest/classes/TZTester/TZTester.html), which parses test cases and\ngenerates a template code file that runs your solution against the test cases locally. Well, that's what this project\naims to do.\n\n\n## Usage\n\n1. Install [Selenium](https://selenium-python.readthedocs.io/installation.html) and the\n   [Chrome web driver](https://sites.google.com/a/chromium.org/chromedriver/downloads) by following instructions\n   in the links.\n\n   **Note:** Although not tested, the code should also work with other web drivers supported by Selenium. Please change\n   the code accordingly if you wish to use alternative browsers.\n2. Clone the repository:\n   ```bash\n   git clone https://github.com/huzecong/leetcode-contest-helper.git\n   cd leetcode-contest-helper\n   ```\n3. Login using your LeetCode account:\n   ```bash\n   python main.py login \u003cusername\u003e\n   ```\n   A browser window will open and navigate to the LeetCode login page. Please enter your credentials and click login\n   (and get pass CAPTCHAs if they pop up).\n\n   If your account is registered on [LeetCode-CN](https://leetcode-cn.com), use this command instead:\n   ```bash\n   python main.py login -s leetcode-cn \u003cusername\u003e\n   ```\n\n   **Note:** Unfortunately, it is not possible to access problem statements without logging in, as LeetCode prevents you\n   from accessing the problems unless you have taken part in the contest or have a premium subscription. LCHelper stores\n   your cookies and uses them to access the problems. Don't worry, your sensitive information is always stored locally.\n\n   **Note:** Third-party login is not supported as of now.\n4. Download problem descriptions and generate testing code in your favorite language:\n   ```bash\n   python main.py get [-l \u003clanguage\u003e] \u003curl-to-contest-page\u003e\n   ```\n   For instance, to generate testing code in C++ and Python for\n   [Weekly Contest 163](https://leetcode.com/contest/weekly-contest-163), run the command:\n   ```bash\n   python main.py get -l cpp -l python -o projects/ https://leetcode.com/contest/weekly-contest-163\n   ```\n   This will generate two folders under the folder `projects/`:\n\n   - `weekly-contest-163_cpp`: C++ code of problems in the contest.\n   - `weekly-contest-163_python`: Python code of problems in the contest.\n\n\n## Instructions for Using Generated Code\n\nThe project folder will contain one code file for each problem, and potentially other files required for compiling or\ntesting. Problems are renamed to single uppercase letters (in the same order as on the web page) for simplicity.\n\nThe generated code contains a certain amount of boilerplate code for debugging. When submitting, remember to copy\neverything between the comments `BEGIN SUBMIT` and `END SUBMIT`.\n\nYou can add your custom code template to the generated code. Currently, this is only possible through modifying the code\nfor LCHelper:\n\n1. Find the code generator class for your language. The C++ generator is located in `lchelper/codegen/cpp.py`, and the\n   Python generator in `lchelper/codegen/python.py`.\n2. Add a property named `user_template_code`, and make it return you code template. The syntax looks like this:\n   ```python\n   @property\n   def user_template_code(self) -\u003e str:\n       return r\"\"\"\n   template \u003ctypename ...Args\u003e\n   void my_amazing_debug_function(Args ...args) {\n       // ...\n   }\n   \"\"\"\n   ```\n   The property might already exist (it does in C++), in this case, feel free to replace it with your own.\n\nSee below for language-specific instructions. Currently, only C++ and Python are supported.\n\n### C++\n\nThe C++ project folder contains these additional files:\n\n- `CMakeLists.txt`, CMake configuration for building the project.\n- `_testing.h`, a header-only library for comparing outputs.\n- `_boilerplate.h`, boilerplate code for LeetCode-specific stuff.\n\nThe generated C++ project builds using CMake. To compile the problems, run the following commands:\n```bash\ncmake .\nmake\n./A  # to run tests for problem A\n```\nYou can also use IDEs (e.g., JetBrains CLion) to automate the process.\n\n\n## Disclaimer\n\n- This tool is not affiliated, associated, authorized, endorsed by, or in any way officially connected with LeetCode.\n- This tool is not guaranteed to generate correct code, although the author tried their best to prevent such cases.\n- This tool is not (and will not be) capable of automatically generating solutions.\n- This tool does not grant you access to premium LeetCode problems that you cannot view with your personal account.\n- Passing test cases within the generated code does not guarantee the correctness of your solution.\n\n\n## TODO\n\n- [ ] Automatic submission \n- [ ] Third-party login\n- [ ] Interactive problems with a query class\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuzecong%2Fleetcode-contest-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuzecong%2Fleetcode-contest-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuzecong%2Fleetcode-contest-helper/lists"}