Skip to content

Commit b22fdbc

Browse files
committed
refactor: rename question to problem
1 parent 2e1f9f1 commit b22fdbc

22 files changed

+90
-90
lines changed

.amazonq/plan/compare_template_files.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def compare_files(file1: Path, file2: Path, label1: str, label2: str) -> bool:
4848

4949
def main(
5050
mode: str = typer.Argument(help="Compare template files or generated files (template|generated)"),
51-
question: str = typer.Option("invert_binary_tree", help="Question name for comparison"),
51+
problem: str = typer.Option("invert_binary_tree", help="Problem name for comparison"),
5252
):
5353
"""Compare files for template validation."""
5454
if mode not in ["template", "generated"]:
@@ -61,21 +61,21 @@ def main(
6161

6262
if mode == "template":
6363
# Compare reference vs template source
64-
dir1 = base_dir / "leetcode" / ".example" / question
65-
dir2 = base_dir / ".templates" / "leetcode" / ".example" / "{{cookiecutter.question_name}}"
64+
dir1 = base_dir / "leetcode" / ".example" / problem
65+
dir2 = base_dir / ".templates" / "leetcode" / ".example" / "{{cookiecutter.problem_name}}"
6666
label1, label2 = "Reference", "Template"
6767
print("TEMPLATE SOURCE ANALYSIS")
6868

6969
elif mode == "generated":
7070
# Compare reference vs currently generated
71-
dir1 = base_dir / "leetcode" / ".example" / question
72-
dir2 = base_dir / "leetcode" / question
71+
dir1 = base_dir / "leetcode" / ".example" / problem
72+
dir2 = base_dir / "leetcode" / problem
7373
label1, label2 = "Reference", "Generated"
7474
print("GENERATED FILES VALIDATION")
7575

7676
if not dir2.exists():
7777
print(f"\n❌ ERROR: Generated directory does not exist: {dir2}")
78-
print(f"Run: make q-gen QUESTION={question}")
78+
print(f"Run: make p-gen PROBLEM={problem}")
7979
return
8080

8181
print(f"{label1}: {dir1}")

.amazonq/plan/cookiecutter-template-plan.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
## TASK PURPOSE & CRITICAL RULES
44

5-
**PURPOSE:** Update the cookiecutter template to generate files that exactly match the reference structure in `.templates/leetcode/.example/{{cookiecutter.question_name}}/`
5+
**PURPOSE:** Update the cookiecutter template to generate files that exactly match the reference structure in `.templates/leetcode/.example/{{cookiecutter.problem_name}}/`
66

77
**REFERENCE DIRECTORIES (NEVER MODIFY - THESE ARE EXAMPLES):**
88

9-
- `.templates/leetcode/.example/{{cookiecutter.question_name}}/` - Shows what the template SHOULD generate
9+
- `.templates/leetcode/.example/{{cookiecutter.problem_name}}/` - Shows what the template SHOULD generate
1010
- `leetcode/.example/` - Generated file examples for comparison
1111

1212
**ACTUAL TEMPLATE DIRECTORY (MODIFY THIS):**
1313

14-
- `.templates/leetcode/{{cookiecutter.question_name}}/` - The cookiecutter template files to update
14+
- `.templates/leetcode/{{cookiecutter.problem_name}}/` - The cookiecutter template files to update
1515

1616
**WORKFLOW:**
1717

18-
1. Look at `.templates/leetcode/.example/{{cookiecutter.question_name}}/` to see target structure
19-
2. Modify `.templates/leetcode/{{cookiecutter.question_name}}/` to match the reference
20-
3. Generate with `make q-gen`
21-
4. Compare generated files vs reference with `make q-validate`
18+
1. Look at `.templates/leetcode/.example/{{cookiecutter.problem_name}}/` to see target structure
19+
2. Modify `.templates/leetcode/{{cookiecutter.problem_name}}/` to match the reference
20+
3. Generate with `make p-gen`
21+
4. Compare generated files vs reference with `make p-validate`
2222

2323
**ERROR PREVENTION:** The template directory does NOT have `.example` in the path!
2424

@@ -38,7 +38,7 @@
3838

3939
- **Tool**: `.amazonq/plan/compare_template_files.py` (already exists - no need to implement)
4040
- **Usage**:
41-
- `poetry run python .amazonq/plan/compare_template_files.py generated --question=QUESTION_NAME` - Compare generated files vs reference
41+
- `poetry run python .amazonq/plan/compare_template_files.py generated --problem=PROBLEM_NAME` - Compare generated files vs reference
4242
- **Analysis**: Line-by-line diff of all file types
4343
- **Document**: Exact differences and required changes
4444
- **Verify**: Template variables handle all variations
@@ -48,27 +48,27 @@
4848
#### Phase 1: Add `__init__.py`
4949

5050
- **Add**: Empty `__init__.py` file to template
51-
- **Validate**: `make q-gen``make q-validate``make lint`
51+
- **Validate**: `make p-gen``make p-validate``make lint`
5252

5353
#### Phase 2: Fix `solution.py`
5454

5555
- **Update**: Modern syntax (`TreeNode | None`), clean template logic
56-
- **Validate**: `make q-gen``make q-validate``make lint`
56+
- **Validate**: `make p-gen``make p-validate``make lint`
5757

5858
#### Phase 3: Fix `tests.py`
5959

6060
- **Update**: Relative imports (`from .solution`), clean structure
61-
- **Validate**: `make q-gen``make q-validate``make lint`
61+
- **Validate**: `make p-gen``make p-validate``make lint`
6262

6363
#### Phase 4: Fix `README.md`
6464

6565
- **Update**: Clean formatting, proper markdown
66-
- **Validate**: `make q-gen``make q-validate``make lint`
66+
- **Validate**: `make p-gen``make p-validate``make lint`
6767

6868
#### Phase 5: Fix `playground.ipynb`
6969

7070
- **Update**: Clean cells without execution state
71-
- **Validate**: `make q-gen``make q-validate``make lint`
71+
- **Validate**: `make p-gen``make p-validate``make lint`
7272

7373
**Benefits**: Isolated debugging, safer progression, easier rollback
7474

@@ -115,36 +115,36 @@
115115
### 5. Template Generation Logic
116116

117117
- **File**: `.templates/leetcode/gen.py` (already handles variable mapping)
118-
- **Integration**: Works with `make q-gen QUESTION=name` (verified in Makefile)
118+
- **Integration**: Works with `make p-gen PROBLEM=name` (verified in Makefile)
119119
- **Update**: Handle new `__init__.py` file
120-
- **Process**: JSON → `gen.py` → cookiecutter → `leetcode/$(QUESTION)/`
120+
- **Process**: JSON → `gen.py` → cookiecutter → `leetcode/$(PROBLEM)/`
121121

122122
### 6. Automated Validation System
123123

124124
- **Tool**: Reusable `.amazonq/plan/compare_template_files.py`
125125
- **Usage**:
126126
```bash
127127
# Validate current template generates correct files
128-
poetry run python .amazonq/plan/compare_template_files.py generated --question=invert_binary_tree
128+
poetry run python .amazonq/plan/compare_template_files.py generated --problem=invert_binary_tree
129129
```
130-
- **Makefile**: `make q-validate QUESTION=name` (implemented)
130+
- **Makefile**: `make p-validate PROBLEM=name` (implemented)
131131
- **Test**: Template regression testing
132-
- **Ensure**: `make q-gen` + `make lint` + `make q-test` all pass
132+
- **Ensure**: `make p-gen` + `make lint` + `make p-test` all pass
133133

134134
### 7. Testing & Validation
135135

136136
- **Test**: Template generation with existing JSON files
137137
- **Verify**: Generated files match `leetcode/.example/` structure exactly
138138
- **Compare**: Automated diff against reference files
139-
- **Ensure**: `make q-gen` works seamlessly
139+
- **Ensure**: `make p-gen` works seamlessly
140140
- **Test**: Recreation process from `.prompt/` files
141141
- **Validate**: Multi-problem type generation
142142

143143
## Key Template Variables to Ensure
144144

145145
```json
146146
{
147-
"question_name": "snake_case_name",
147+
"problem_name": "snake_case_name",
148148
"class_name": "PascalCaseName",
149149
"method_name": "snake_case_method",
150150
"problem_number": "226",
@@ -181,16 +181,16 @@
181181
### Automated Validation
182182

183183
8. ✅ Automated diff shows no differences vs `leetcode/.example/`
184-
9. ✅ `make q-validate` passes for all problem types
184+
9. ✅ `make p-validate` passes for all problem types
185185
10. ✅ Recreation from `.prompt/` works flawlessly
186186
11. ✅ All linting passes (`make lint`)
187-
12. ✅ Tests run successfully (`make q-test`)
187+
12. ✅ Tests run successfully (`make p-test`)
188188

189189
## Files to Modify
190190

191191
### Template Files
192192

193-
1. `.templates/leetcode/{{cookiecutter.question_name}}/`
193+
1. `.templates/leetcode/{{cookiecutter.problem_name}}/`
194194
- **Add**: `__init__.py` (empty file)
195195
- **Update**: `solution.py` (modern syntax, imports)
196196
- **Update**: `tests.py` (match `leetcode/.example/` format)
@@ -212,7 +212,7 @@
212212
### Validation Tools
213213

214214
4. **Reusable**: `.amazonq/plan/compare_template_files.py` (handles both template and generated comparisons)
215-
5. **New**: Makefile target `make q-validate`
215+
5. **New**: Makefile target `make p-validate`
216216

217217
## Risk Mitigation
218218

.amazonq/rules/development-rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
## Testing
1616

17-
- Test specific: `make q-test QUESTION=<name>`
17+
- Test specific: `make p-test PROBLEM=<name>`
1818
- Test all: `make test`
1919
- Beautiful logging with loguru
2020

.amazonq/rules/question-creation.md renamed to .amazonq/rules/problem-creation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Question Creation Guide
1+
# Problem Creation Guide
22

33
## Quick Steps
44

5-
1. Create JSON: `.templates/leetcode/json/{question_name}.json`
6-
2. Update Makefile: `QUESTION ?= your_new_question`
7-
3. Generate: `make q-gen`
5+
1. Create JSON: `.templates/leetcode/json/{problem_name}.json`
6+
2. Update Makefile: `PROBLEM ?= your_new_problem`
7+
3. Generate: `make p-gen`
88
4. Verify: `make lint`
9-
5. **If you edit generated files**: Update JSON template, then `make q-gen FORCE=1` to ensure reproducibility
9+
5. **If you edit generated files**: Update JSON template, then `make p-gen FORCE=1` to ensure reproducibility
1010

1111
## JSON Template Rules
1212

@@ -15,7 +15,7 @@
1515
- **Basic problems**: Use `.templates/leetcode/examples/basic.json5`
1616
- **Don't add extra fields** - templates are complete
1717
- **If lint fails**: Fix JSON and regenerate, don't edit generated files
18-
- **After any manual edits**: Always update JSON template and verify with `make q-gen FORCE=1`
18+
- **After any manual edits**: Always update JSON template and verify with `make p-gen FORCE=1`
1919

2020
## Tags (Optional)
2121

.templates/leetcode/cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"question_name": "two_sum",
2+
"problem_name": "two_sum",
33
"class_name": "TwoSum",
44
"method_name": "two_sum",
55
"problem_number": "1",

.templates/leetcode/examples/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Reference templates for creating new LeetCode problems. **Copy from these exampl
55
## Usage
66

77
1. **Choose the right template** based on problem type
8-
2. **Copy the entire structure** to `.templates/leetcode/json/{question_name}.json`
8+
2. **Copy the entire structure** to `.templates/leetcode/json/{problem_name}.json`
99
3. **Update all fields** with your problem's data
10-
4. **Generate**: `make q-gen QUESTION=your_question`
10+
4. **Generate**: `make p-gen PROBLEM=your_problem`
1111

1212
## Templates
1313

@@ -45,7 +45,7 @@ Reference templates for creating new LeetCode problems. **Copy from these exampl
4545

4646
### Required Core Fields
4747

48-
- `question_name`, `class_name`, `method_name`
48+
- `problem_name`, `class_name`, `method_name`
4949
- `problem_number`, `problem_title`, `difficulty`, `topics`
5050
- `problem_description`, `examples`, `constraints`
5151
- `parameters`, `return_type`, `dummy_return`
@@ -68,4 +68,4 @@ Reference templates for creating new LeetCode problems. **Copy from these exampl
6868
1. **Copy structure exactly** - all fields are required
6969
2. **Use modern Python syntax**: `list[int]`, `TreeNode | None`
7070
3. **Match existing patterns** - see current JSON files for reference
71-
4. **Test thoroughly** - run `make lint` and `make q-test` after generation
71+
4. **Test thoroughly** - run `make lint` and `make p-test` after generation

.templates/leetcode/examples/basic.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Copy this structure when creating new basic problems
44

55
// REQUIRED: Core identifiers
6-
"question_name": "two_sum",
6+
"problem_name": "two_sum",
77
"class_name": "TwoSum",
88
"method_name": "two_sum",
99

.templates/leetcode/examples/linked_list.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use this for problems involving ListNode structures
44

55
// REQUIRED: Core identifiers
6-
"question_name": "reverse_linked_list_ii",
6+
"problem_name": "reverse_linked_list_ii",
77
"class_name": "ReverseLinkedListII",
88
"method_name": "reverse_between",
99

.templates/leetcode/examples/matrix.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use this for 2D array/matrix problems
44

55
// REQUIRED: Core identifiers
6-
"question_name": "rotate_image",
6+
"problem_name": "rotate_image",
77
"class_name": "RotateImage",
88
"method_name": "rotate",
99

.templates/leetcode/examples/string.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use this for string manipulation problems
44

55
// REQUIRED: Core identifiers
6-
"question_name": "valid_palindrome",
6+
"problem_name": "valid_palindrome",
77
"class_name": "ValidPalindrome",
88
"method_name": "is_palindrome",
99

0 commit comments

Comments
 (0)