|
| 1 | +# LLM-Assisted Problem Creation Guide |
| 2 | + |
| 3 | +This guide demonstrates how to leverage Large Language Models (LLMs) like Amazon Q, GitHub Copilot Chat, or Cursor to automatically generate new LeetCode problems for your practice environment. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The LLM-assisted workflow enables you to add new problems to your collection with a simple natural language command. The AI assistant handles the entire process from scraping problem data to generating the complete problem structure with comprehensive test cases. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +### Required LLM Context |
| 12 | + |
| 13 | +For optimal results, include these rule files in your LLM context: |
| 14 | + |
| 15 | +- [`.amazonq/rules/problem-creation.md`](../.amazonq/rules/problem-creation.md) - Complete problem generation workflow |
| 16 | +- [`.amazonq/rules/test-quality-assurance.md`](../.amazonq/rules/test-quality-assurance.md) - Test enhancement and reproducibility verification |
| 17 | +- [`.amazonq/rules/development-rules.md`](../.amazonq/rules/development-rules.md) - Code standards and testing patterns |
| 18 | + |
| 19 | +### Setup Your IDE |
| 20 | + |
| 21 | +Configure your IDE with an LLM assistant: |
| 22 | + |
| 23 | +- **Amazon Q**: Install the Amazon Q plugin |
| 24 | +- **GitHub Copilot**: Enable Copilot Chat |
| 25 | +- **Cursor**: Built-in AI assistant |
| 26 | +- **Other**: Any IDE with LLM integration |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +### Basic Problem Addition |
| 31 | + |
| 32 | +Simply ask your LLM assistant to add a problem: |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +_Example prompt showing how to request a new problem with the LLM assistant_ |
| 37 | + |
| 38 | +```bash |
| 39 | +# Simple commands that work: |
| 40 | +"Add problem 198. House Robber" |
| 41 | +"Add problem 198. House Robber. tag: grind" |
| 42 | +"Create problem 70. Climbing Stairs with grind-75 tag" |
| 43 | +``` |
| 44 | + |
| 45 | +### What Happens Automatically |
| 46 | + |
| 47 | +The LLM assistant will execute the complete workflow: |
| 48 | + |
| 49 | +1. **Scrape** problem data from LeetCode |
| 50 | +2. **Transform** data into proper JSON template format (including images) |
| 51 | +3. **Create** JSON file in `leetcode_py/cli/resources/leetcode/json/problems/{problem_name}.json` |
| 52 | +4. **Update** `leetcode_py/cli/resources/leetcode/json/tags.json5` with specified tags |
| 53 | +5. **Generate** complete problem structure in `leetcode/{problem_name}/` |
| 54 | +6. **Verify** with linting checks (iterates from step 3 until all pass) |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +_Source control view showing all files created and modified during the problem generation process_ |
| 59 | + |
| 60 | +## Generated Problem Structure |
| 61 | + |
| 62 | +### Solution Template |
| 63 | + |
| 64 | +The assistant generates a clean solution template with proper type hints: |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +_Generated solution.py file with TODO placeholder and proper method signature_ |
| 69 | + |
| 70 | +### Comprehensive Test Suite |
| 71 | + |
| 72 | +Each problem includes 10+ test cases covering edge cases (note: generated test cases may need verification for correctness): |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +_Generated test_solution.py with parametrized tests and comprehensive test cases_ |
| 77 | + |
| 78 | +## Test Enhancement Workflow |
| 79 | + |
| 80 | +### Enhancing Existing Problems |
| 81 | + |
| 82 | +Improve test coverage for existing problems: |
| 83 | + |
| 84 | +```bash |
| 85 | +"Enhance test cases for two_sum problem" |
| 86 | +"Add more edge cases to binary_tree_inorder_traversal" |
| 87 | +"Fix test reproducibility for valid_palindrome" |
| 88 | +``` |
| 89 | + |
| 90 | +### Quality Assurance |
| 91 | + |
| 92 | +The assistant can identify problems needing more test cases and verify test case correctness and reproducibility: |
| 93 | + |
| 94 | +```bash |
| 95 | +"Check which problems need more test cases" |
| 96 | +"Find problems with less than 12 test cases" |
| 97 | +"Verify test case correctness for house_robber" |
| 98 | +"Fix test reproducibility for binary_tree_inorder_traversal" |
| 99 | +``` |
| 100 | + |
| 101 | +## Best Practices |
| 102 | + |
| 103 | +### Effective Prompts |
| 104 | + |
| 105 | +**Good prompts:** |
| 106 | + |
| 107 | +- "Add problem 198. House Robber with grind tag" |
| 108 | +- "Create problem 70. Climbing Stairs for grind-75" |
| 109 | +- "Enhance test cases for two_sum problem" |
| 110 | + |
| 111 | +**Avoid:** |
| 112 | + |
| 113 | +- Vague requests without problem numbers |
| 114 | +- Requests for non-existent problems |
| 115 | + |
| 116 | +## Troubleshooting |
| 117 | + |
| 118 | +### Common Issues |
| 119 | + |
| 120 | +**Template errors:** |
| 121 | + |
| 122 | +- Assistant will automatically fix JSON template issues |
| 123 | +- Re-runs generation until linting passes |
| 124 | +- If JSON template fails after many iterations, ask agent to review the example template carefully as mentioned in the rules |
| 125 | + |
| 126 | +**Test failures:** |
| 127 | + |
| 128 | +- Assistant verifies test cases against expected outputs |
| 129 | +- Fixes incorrect expected values |
| 130 | +- Use test QA workflow for comprehensive test enhancement and reproducibility verification |
| 131 | + |
| 132 | +## Integration with Development Workflow |
| 133 | + |
| 134 | +### CI/CD Compatibility |
| 135 | + |
| 136 | +Generated problems integrate seamlessly with: |
| 137 | + |
| 138 | +- **Test Reproducibility** - CI automatically verifies problems can be regenerated consistently; just implement your solution and CI handles the rest |
| 139 | + |
| 140 | +## Conclusion |
| 141 | + |
| 142 | +LLM-assisted problem creation transforms the tedious process of adding new problems into a simple natural language interaction. The assistant handles all the complexity while ensuring professional code quality and comprehensive test coverage. |
| 143 | + |
| 144 | +Start practicing with your new problems immediately - the assistant takes care of everything else! |
0 commit comments