Every Accepted was paid in blood, sweat, and runtime errors.
Note: This repository is a work in progress. Expect ongoing improvements and refinements!
- Overview
- Features
- Installation
- The Workflow: A Quick Start
- Command Usage
- Configuration
- File & Folder Structure
- Contributing & Support
- License
- OpenAI API Usage (Optional)
Scars of LeetCode is a repository powered by Scarleet, a command-line tool designed to automate and streamline the entire workflow for mastering LeetCode problems. It helps you:
- Organize solutions in a structured way.
- Automatically generate high-quality documentation for solved problems.
- Create evidence-based, spaced-repetition flashcards for deep learning.
- Track your progress with a dynamic summary table.
- Seamlessly integrate with Anki for efficient review.
This project is for anyone who wants to build a deep, recallable understanding of algorithms and data structures through a powerful, automated system.
- CLI-Driven Workflow: Manage your entire practice from the command line.
- Automated Scaffolding: Instantly create a structured directory for any LeetCode problem.
- AI-Powered Documentation: Use a local language model to automatically generate high-quality READMEs explaining your solution's intuition, approach, and complexity.
- Automated Flashcard Generation: Turn your solutions into effective Anki flashcards (both Q&A and Cloze deletion) with a single command.
- Intelligent Anki Integration: Automatically detects your environment (including WSL) to connect to Anki and sync cards without manual configuration.
- Progress Tracking: Generate a summary table of your progress at any time.
Prerequisites:
- Python 3.8+
- Ollama for running the local language model.
- Anki desktop application with the AnkiConnect add-on installed.
Setup Steps:
- Clone the repository:
git clone [https://github.com/scarowar/scars-of-leetcode.git](https://github.com/scarowar/scars-of-leetcode.git) cd scars-of-leetcode
- Install the required Python packages:
pip install "typer[all]" rich toml requests
- Run the interactive setup command. This will create your configuration file, check for Ollama, and download the recommended language model.
python main.py setup
You can install all dependencies with either:
pip install -r requirements.txt
or, if you prefer PEP 621/modern Python packaging:
pip install .
Both methods will install all required packages for Scarleet.
See INSTALL.md for more details.
The entire process is designed to be simple and flow naturally with your practice.
- Create a New Problem:
scarleet new <problem-slug> # Example: scarleet new two-sum
- Solve It: Navigate to the new
problems/[id]-[slug]
directory and write your solution insolution.py
. - Generate Docs: After your solution is accepted on LeetCode, let Scarleet document it for you.
scarleet docgen <problem-slug>
- Create Flashcards: Turn your documented solution into study material.
scarleet flashcards <problem-slug>
- Track Your Progress: View a summary of all your solved problems and update the master
README.md
.scarleet status --update-readme
setup
: Initializes the project. Should be run once.new <slug>
: Scaffolds a new problem directory.docgen <slug>
: Generates aREADME.md
for a problem using your solution and the local SLM.flashcards <slug>
: Generates Anki flashcards from yourREADME.md
and solution.status
: Displays a summary table of all problems. Use the--update-readme
or-u
flag to write this table toproblems/README.md
.
All configuration is managed in the scarleet.toml
file, which is created by the setup
command. Here you can change:
- The language model used (e.g., from
gemma:2b
to another Ollama model). - The prompts used for generating documentation and flashcards.
- The name of your Anki deck.
.
├── scarleet.toml # Global configuration for the tool
├── main.py # The CLI entrypoint
├── commands/ # Logic for each CLI command
├── core/ # Core logic for Anki, SLM, and LeetCode API
├── problems/
│ ├── ... # One folder per problem, each with solution and docs
│ └── README.md # Auto-generated progress summary
└── .scarleet/
└── lists/
├── blind75.json # Blind 75 list
└── neetcode150.json # NeetCode 150 list
Scarleet can use either OpenAI or Azure OpenAI models (like GPT-4, GPT-3.5, etc.) for generating flashcards and documentation. To enable this, set the following environment variables in a .env
file (which should NOT be committed to version control):
OPENAI_API_KEY=sk-...your-key...
OPENAI_API_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o
OPENAI_API_VERSION=2024-06-01
AZURE_API_KEY=your-azure-key
AZURE_API_BASE=https://your-resource.openai.azure.com
AZURE_DEPLOYMENT_NAME=your-deployment
AZURE_API_VERSION=2024-06-01
- Scarleet will auto-detect which provider to use based on your
.env
. - If neither is set, Scarleet will use your local SLM endpoint as a fallback.
- Install dependencies for .env support:
pip install python-dotenv
- The
openai
Python package is required (seerequirements.txt
).
Never commit your .env
file or API keys to version control.
Contributions, suggestions, and improvements are welcome! Please open an issue or PR. By contributing, you agree that your contributions will be licensed under the GNU General Public License v3.0.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Happy grinding — and may your scars become your strength!