A LeetCode project template generator.
Project description
LeetCode Project Generator
Practice LeetCode Locally with Ease
LPG is a powerful tool that facilitates the generation of local solution and test files for LeetCode problems. Say goodbye to the web-based runner and hello to seamless local development. With LPG, you can write, test, and refine your solutions in the comfort of your own environment. A CLI tool created using Click.
Installation
From PyPI
pip install leetcode-project-generator
From source
python -m pip install setuptools, build
python -m build
python -m pip install ./dist/leetcode_project_generator-*-py3-none-any.whl
Usage
[!TIP] LPG allows you to generate the project files for a given problem by just copy and pasting the URL from LeetCode!
Installed package
lpg (--title_slug <problem title> | --url <problem url>) [--directory <project directory>] [--lang <language>] [--force] [--git-init] [--git-commit] [--git-commit-message <message>]
Local package
python -m lpg (--title_slug <problem title> | --url <problem url>) [--directory <project directory>] [--lang <language>] [--force] [--git-init] [--git-commit] [--git-commit-message <message>]
Explanation
"Title slug" refers to the dashed title of the LeetCode problem which can be found in the URL of the problem.
E.g. for https://leetcode.com/problems/two-sum/description/, the title slug is two-sum.
The default language is C. For an updated list of supported languages, refer to the roadmap or the related issue.
If using Bash, you must surround the URL with quotes, since the & symbol would be interpreted as an asynchronous command.
The project directory defaults to ~/Documents/Coding/{language_name}/. You may use use the template {language_name} when specifying the directory, and this will automatically be translated into the name of the language specified using --lang. E.g.: cpp -> C++.
The project will be created in its own directory with the name of the title slug within this directory. This is unchangeable.
Example
If you want to initialise a project for https://leetcode.com/problems/two-sum/description/, then you might type:
lpg -d /path/to/project -l c 'https://leetcode.com/problems/two-sum/description/'
This will create a directory called /path/to/project/two-sum and fill it with C language skeleton files. In this case, specifying -l c is redundant since C is the default language.
For more syntax help, use the help option.
lpg --help
or
python -m lpg --help
Roadmap
Planned available languages:
- python
- python3 (thanks @dancikmad)
- javascript
- typescript
- c
- cpp
- csharp
- java
- php
- swift
- kotlin
- dart
- golang (thanks @dancikmad)
- ruby
- scala
- rust
- racket
- erlang
- elixir
Contributing
Know any of the above langauges and want to help out? Your contributions will be greatly appreciated!
For more information on how to implement the language interface, refer to this issue. Then, fork this repository, make your changes and submit them as a pull request.
Testing
You can test all registered language interfaces (including your implementation) by running the test file found at src/lpg/interfaces/lang_test.py:
python -m unittest src.lpg.interfaces.lang_test
This uses the builtin unittest module and executes project generation for each language against an arbitrary list of LeetCode problems in a temporary directory, which is then cleaned up.
Thanks for reading!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leetcode_project_generator-1.6.0.tar.gz.
File metadata
- Download URL: leetcode_project_generator-1.6.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaaf4a762e8c7fe95bea432c4b9e631d3f7735ab49461aca3d050632e3f3207e
|
|
| MD5 |
32b4242fd6e595564c0bb0597da7a0b9
|
|
| BLAKE2b-256 |
a572b46633a8165dbb9693ec819a5f768d72cfd8a821bbf04898d34793e6c034
|
Provenance
The following attestation bundles were made for leetcode_project_generator-1.6.0.tar.gz:
Publisher:
python-publish.yml on kguzek/leetcode-project-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leetcode_project_generator-1.6.0.tar.gz -
Subject digest:
aaaf4a762e8c7fe95bea432c4b9e631d3f7735ab49461aca3d050632e3f3207e - Sigstore transparency entry: 186867944
- Sigstore integration time:
-
Permalink:
kguzek/leetcode-project-generator@b41f1f1a82fe39dc83f1dce5e460b7e2cb7647ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kguzek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b41f1f1a82fe39dc83f1dce5e460b7e2cb7647ea -
Trigger Event:
push
-
Statement type:
File details
Details for the file leetcode_project_generator-1.6.0-py3-none-any.whl.
File metadata
- Download URL: leetcode_project_generator-1.6.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a00b940d042e070493860c31988cad0e0e79e94a66fffb9cb2280ee09a37377
|
|
| MD5 |
f92d825efc24d8318247370b064d1216
|
|
| BLAKE2b-256 |
99c80e18ce9bbdcf82040227530ee759449c2dcc40c12f82ea409bcc376294ea
|
Provenance
The following attestation bundles were made for leetcode_project_generator-1.6.0-py3-none-any.whl:
Publisher:
python-publish.yml on kguzek/leetcode-project-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leetcode_project_generator-1.6.0-py3-none-any.whl -
Subject digest:
8a00b940d042e070493860c31988cad0e0e79e94a66fffb9cb2280ee09a37377 - Sigstore transparency entry: 186867945
- Sigstore integration time:
-
Permalink:
kguzek/leetcode-project-generator@b41f1f1a82fe39dc83f1dce5e460b7e2cb7647ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kguzek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b41f1f1a82fe39dc83f1dce5e460b7e2cb7647ea -
Trigger Event:
push
-
Statement type: