Skip to content

Commit 85d763c

Browse files
authored
docs: update README.md (#47)
- update README.md - update agent rules - add llm-assisted-problem-creation.md
1 parent 9080a82 commit 85d763c

29 files changed

+480
-78
lines changed

.amazonq/rules/problem-creation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
When user requests a problem by **number** or **name/slug**, the assistant will:
66

7-
1. **Scrape** problem data using `lcpy scrape`
7+
1. **Scrape** problem data using `poetry run lcpy scrape`
88
2. **Transform** data into proper JSON template format
99
3. **CRITICAL: Include images** - Extract image URLs from scraped data and add to readme_examples with format: `![Example N](image_url)\n\n` before code blocks
1010
- Check scraped data for image URLs in the `raw_content` field
@@ -23,10 +23,10 @@ When user requests a problem by **number** or **name/slug**, the assistant will:
2323

2424
```bash
2525
# Fetch by number
26-
lcpy scrape -n 1
26+
poetry run lcpy scrape -n 1
2727

2828
# Fetch by slug
29-
lcpy scrape -s "two-sum"
29+
poetry run lcpy scrape -s "two-sum"
3030
```
3131

3232
## JSON Template Format

.amazonq/rules/test-quality-assurance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mv .cache/leetcode/{problem_name} leetcode/{problem_name}
5959

6060
```bash
6161
# Generate enhanced problem
62-
lcpy gen -s {problem_name} -o leetcode --force
62+
poetry run lcpy gen -s {problem_name} -o leetcode --force
6363

6464
# Test specific problem
6565
make p-test PROBLEM={problem_name}
@@ -80,7 +80,7 @@ poetry run python -m leetcode_py.tools.check_test_cases --threshold=10 --max=non
8080
# Check with custom threshold
8181
poetry run python -m leetcode_py.tools.check_test_cases --threshold=12
8282

83-
# Generate from JSON template (uses lcpy internally)
83+
# Generate from JSON template (uses poetry run lcpy internally)
8484
make p-gen PROBLEM={problem_name} FORCE=1
8585
```
8686

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PYTHON_VERSION = 3.13
2-
PROBLEM ?= daily_temperatures
2+
PROBLEM ?= house_robber
33
FORCE ?= 0
44
COMMA := ,
55

README.md

Lines changed: 96 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LeetCode Practice Repository 🚀
1+
# LeetCode Practice Environment Generator 🚀
22

33
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=wisarootl_leetcode-py&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wisarootl_leetcode-py)
44
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=wisarootl_leetcode-py&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=wisarootl_leetcode-py)
@@ -7,11 +7,11 @@
77
[![tests](https://img.shields.io/github/actions/workflow/status/wisarootl/leetcode-py/ci-test.yml?branch=main&label=tests&logo=github)](https://github.com/wisarootl/zerv/actions/workflows/ci-test.yml)
88
[![release](https://img.shields.io/github/actions/workflow/status/wisarootl/leetcode-py/cd.yml?branch=main&label=release&logo=github)](https://github.com/wisarootl/zerv/actions/workflows/cd.yml)
99

10-
A modern Python LeetCode practice environment that goes beyond basic problem solving. Features automated problem generation from LeetCode URLs, beautiful data structure visualizations (TreeNode, ListNode, GraphNode), and comprehensive testing with 12+ test cases per problem. Built with professional development practices including CI/CD, type hints, and quality gates.
10+
A Python package to generate professional LeetCode practice environments. Features automated problem generation from LeetCode URLs, beautiful data structure visualizations (TreeNode, ListNode, GraphNode), and comprehensive testing with 10+ test cases per problem. Built with professional development practices including CI/CD, type hints, and quality gates.
1111

1212
**What makes this different:**
1313

14-
- 🤖 **LLM-Assisted Workflow**: Generate new problems instantly with AI assistance
14+
- 🤖 **[LLM-Assisted Workflow](#llm-assisted-problem-creation)**: Generate new problems instantly with AI assistance
1515
- 🎨 **Visual Debugging**: Interactive tree/graph rendering with Graphviz and anytree
1616
- 🧪 **Production Testing**: Comprehensive test suites with edge cases and reproducibility verification
1717
- 🚀 **Modern Python**: PEP 585/604 type hints, Poetry, and professional tooling
@@ -21,46 +21,47 @@ A modern Python LeetCode practice environment that goes beyond basic problem sol
2121

2222
**Current**: All 75 problems from [Grind 75](https://www.techinterviewhandbook.org/grind75/) - the most essential coding interview questions curated by the creator of Blind 75.
2323

24-
**Future**: Planned expansion to all 169 Grind problems for comprehensive interview preparation.
24+
**Future**: Planned expansion to all free Grind problems for comprehensive interview preparation.
2525

2626
## 🚀 Quick Start
2727

28-
### CLI Installation (Recommended)
28+
### System Requirements
29+
30+
- **Python 3.13+** - Modern Python runtime with latest type system features
31+
- **Poetry** - Dependency management and packaging
32+
- **Make** - Build automation (development workflows)
33+
- **Git** - Version control system
34+
- **Graphviz** - Graph visualization library (for data structure rendering)
2935

3036
```bash
31-
# Install globally via pip
37+
# Install the package
3238
pip install leetcode-py
3339

3440
# Generate problems anywhere
3541
lcpy gen -n 1 # Generate Two Sum
3642
lcpy gen -t grind-75 # Generate all Grind 75 problems
3743
lcpy list -t grind-75 # List available problems
3844
lcpy scrape -n 1 # Fetch problem data
45+
46+
# Start practicing
47+
cd leetcode/two_sum
48+
python -m pytest test_solution.py # Run tests
49+
# Edit solution.py, then rerun tests
3950
```
4051

41-
### Development Setup
52+
### Example
4253

4354
```bash
44-
# Clone and setup for development
45-
git clone https://github.com/wisarootl/leetcode-py.git
46-
cd leetcode-py
47-
poetry install
48-
49-
# Start with existing Grind 75 problems
50-
make gen-all-problems # Regenerates all problems with TODO placeholders
55+
lcpy gen --problem-tag grind-75 --output leetcode # Generate all Grind 75 problems
56+
```
5157

52-
# Practice a specific problem
53-
make p-test PROBLEM=two_sum
54-
# Edit leetcode/two_sum/solution.py, then rerun tests
58+
![Problem Generation](docs/images/problems-generation.png)
5559

56-
# Run all tests
57-
make test
58-
```
60+
_Bulk generation output showing "Generated problem:" messages for all 75 Grind problems_
5961

60-
## 📋 Prerequisites
62+
![Problem Generation 2](docs/images/problems-generation-2.png)
6163

62-
- Python 3.13+
63-
- Poetry, Make, Git, Graphviz
64+
_Generated folder structure showing all 75 problem directories after command execution_
6465

6566
## 📁 Problem Structure
6667

@@ -70,42 +71,77 @@ Each problem follows a consistent, production-ready template:
7071
leetcode/two_sum/
7172
├── README.md # Problem description with examples and constraints
7273
├── solution.py # Implementation with type hints and TODO placeholder
73-
├── test_solution.py # Comprehensive parametrized tests (12+ test cases)
74+
├── test_solution.py # Comprehensive parametrized tests (10+ test cases)
7475
├── helpers.py # Test helper functions
7576
├── playground.py # Interactive debugging environment (converted from .ipynb)
7677
└── __init__.py # Package marker
7778
```
7879

80+
![README Example](docs/images/readme-example.png)
81+
82+
_README format that mirrors LeetCode's problem description layout_
83+
84+
![Solution Boilerplate](docs/images/solution-boilerplate.png)
85+
86+
_Solution boilerplate with type hints and TODO placeholder_
87+
88+
![Test Example](docs/images/test-example.png)
89+
90+
_Comprehensive parametrized tests with 10+ test cases - executable and debuggable in local development environment_
91+
92+
![Test Logging](docs/images/logs-in-test-solution.png)
93+
94+
_Beautiful colorful test output with loguru integration for enhanced debugging and test result visualization_
95+
7996
## ✨ Key Features
8097

8198
### Production-Grade Development Environment
8299

83100
- **Modern Python**: PEP 585/604 type hints, snake_case conventions
84101
- **Comprehensive Linting**: black, isort, ruff, mypy with nbqa for notebooks
85-
- **High Test Coverage**: 12+ test cases per problem including edge cases
102+
- **High Test Coverage**: 10+ test cases per problem including edge cases
86103
- **Beautiful Logging**: loguru integration for enhanced test debugging
87104
- **CI/CD Pipeline**: Automated testing, security scanning, and quality gates
88105

89106
### Enhanced Data Structure Visualization
90107

91-
- **TreeNode**: Beautiful tree rendering with anytree and Graphviz
92-
- **ListNode**: Clean arrow-based visualization (`1 -> 2 -> 3`)
93-
- **Interactive Debugging**: Multi-cell playground environment
108+
Professional-grade visualization for debugging complex data structures with dual rendering modes:
109+
110+
- **TreeNode**: Beautiful tree rendering with anytree and Graphviz integration
111+
- **ListNode**: Clean arrow-based visualization with cycle detection
112+
- **GraphNode**: Interactive graph rendering for adjacency list problems
113+
- **DictTree**: Box-drawing character trees perfect for Trie implementations
114+
115+
#### Jupyter Notebook Integration (HTML Rendering)
94116

95-
![Tree Visualization](https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/tree-viz.png)
96-
_Beautiful tree rendering with anytree and Graphviz_
117+
![Tree Visualization](docs/images/tree-viz.png)
97118

98-
![LinkedList Visualization](https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/linkedlist-viz.png)
99-
_Clean arrow-based list visualization_
119+
_Interactive tree visualization using Graphviz SVG rendering in Jupyter notebooks_
120+
121+
![LinkedList Visualization](docs/images/linkedlist-viz.png)
122+
123+
_Professional linked list visualization with Graphviz in Jupyter environment_
124+
125+
#### Terminal/Console Output (String Rendering)
126+
127+
![Tree String Visualization](docs/images/tree-str-viz.png)
128+
129+
_Clean ASCII tree rendering using anytree for terminal debugging and logging_
130+
131+
![LinkedList String Visualization](docs/images/linkedlist-str-viz.png)
132+
133+
_Simple arrow-based list representation for console output and test debugging_
100134

101135
### Flexible Notebook Support
102136

103-
- **Template Generation**: Creates Jupyter notebooks (`.ipynb`) by default
104-
- **Repository State**: This repo uses Python files (`.py`) for better version control
105-
- **User Choice**: Use `make nb-to-py` to convert notebooks to Python files, or keep as `.ipynb` for interactive development
137+
- **Template Generation**: Creates Jupyter notebooks (`.ipynb`) by default with rich data structure rendering
138+
- **User Choice**: Use `jupytext` to convert notebooks to Python files, or keep as `.ipynb` for interactive exploration
139+
- **Repository State**: This repo converts them to Python files (`.py`) for better version control
140+
- **Dual Rendering**: Automatic HTML visualization in notebooks, clean string output in terminals
106141

107-
![Notebook Example](https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/notebook-example.png)
108-
_Interactive multi-cell playground for each problem_
142+
![Notebook Example](docs/images/notebook-example.png)
143+
144+
_Interactive multi-cell playground with rich data structure visualization for each problem_
109145

110146
## 🔄 Usage Patterns
111147

@@ -131,31 +167,38 @@ lcpy list -d Medium # Filter by difficulty
131167
lcpy scrape -n 1 > two_sum.json # Save problem data
132168
```
133169

134-
### Development Workflow
170+
## 🛠️ Development Setup
135171

136-
For repository development and customization:
172+
For working within this repository to generate additional LeetCode problems using LLM assistance:
137173

138174
```bash
139-
# Regenerate all 75 problems with fresh TODO placeholders
140-
make gen-all-problems
175+
# Clone repository for development
176+
git clone https://github.com/wisarootl/leetcode-py.git
177+
cd leetcode-py
178+
poetry install
179+
180+
# Generate problems from JSON templates
181+
make p-gen PROBLEM=problem_name
182+
make p-test PROBLEM=problem_name
141183

142-
# Work through problems systematically
143-
make p-test PROBLEM=two_sum
144-
make p-test PROBLEM=valid_palindrome
145-
make p-test PROBLEM=merge_two_sorted_lists
184+
# Regenerate all existing problems
185+
make gen-all-problems
146186
```
147187

148188
### LLM-Assisted Problem Creation
149189

150-
If you need more problems beyond Grind 75, use an LLM assistant in your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.):
190+
To extend the problem collection beyond the current catalog, leverage an LLM assistant within your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.).
191+
192+
📖 **[Complete LLM-Assisted Problem Creation Guide](docs/llm-assisted-problem-creation.md)** - Comprehensive guide with screenshots and detailed workflow.
193+
194+
**Quick Start:**
151195

152196
```bash
153-
# Example commands to give your LLM assistant:
154-
"Create LeetCode problem 146 (LRU Cache)"
155-
"Add problem 'Word Ladder' by number 127"
156-
"Generate problem 'Serialize and Deserialize Binary Tree'"
197+
# Problem generation commands:
198+
"Add problem 198. House Robber"
199+
"Add problem 198. House Robber. tag: grind"
157200

158-
# For test enhancement (when you need more comprehensive test coverage):
201+
# Test enhancement commands:
159202
"Enhance test cases for two_sum problem"
160203
"Fix test reproducibility for binary_tree_inorder_traversal"
161204
```
@@ -201,6 +244,8 @@ poetry run python -m leetcode_py.tools.check_test_cases --threshold=10
201244

202245
### CLI Commands (Global)
203246

247+
📖 **[Complete CLI Usage Guide](docs/cli-usage.md)** - Detailed documentation with all options and examples.
248+
204249
```bash
205250
# Generate problems
206251
lcpy gen -n 1 # Single problem by number

docs/images/generated-solution.png

57 KB
Loading

docs/images/generated-test.png

203 KB
Loading

docs/images/linkedlist-str-viz.png

21.2 KB
Loading
153 KB
Loading
121 KB
Loading
34.6 KB
Loading

0 commit comments

Comments
 (0)