From dafd1c2c011c93b4ef6a54c969cde64d3b22e11b Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Fri, 19 Sep 2025 11:58:24 +0700 Subject: [PATCH] feat: add more porblem and fix test issue --- .amazonq/rules/problem-creation.md | 227 +++++++++++++++++- Makefile | 4 +- .../pacific_atlantic_water_flow/README.md | 59 +++++ .../pacific_atlantic_water_flow/__init__.py | 0 .../pacific_atlantic_water_flow/helpers.py | 8 + .../pacific_atlantic_water_flow/playground.py | 29 +++ .../pacific_atlantic_water_flow/solution.py | 37 +++ .../test_solution.py | 170 +++++++++++++ leetcode/valid_sudoku/test_solution.py | 16 -- .../resources/leetcode/examples/example.json5 | 200 --------------- .../problems/pacific_atlantic_water_flow.json | 74 ++++++ .../leetcode/json/problems/valid_sudoku.json | 2 +- .../cli/resources/leetcode/json/tags.json5 | 1 + leetcode_py/tools/check_test_cases.py | 23 +- 14 files changed, 617 insertions(+), 233 deletions(-) create mode 100644 leetcode/pacific_atlantic_water_flow/README.md create mode 100644 leetcode/pacific_atlantic_water_flow/__init__.py create mode 100644 leetcode/pacific_atlantic_water_flow/helpers.py create mode 100644 leetcode/pacific_atlantic_water_flow/playground.py create mode 100644 leetcode/pacific_atlantic_water_flow/solution.py create mode 100644 leetcode/pacific_atlantic_water_flow/test_solution.py delete mode 100644 leetcode_py/cli/resources/leetcode/examples/example.json5 create mode 100644 leetcode_py/cli/resources/leetcode/json/problems/pacific_atlantic_water_flow.json diff --git a/.amazonq/rules/problem-creation.md b/.amazonq/rules/problem-creation.md index 8159741..97e2a21 100644 --- a/.amazonq/rules/problem-creation.md +++ b/.amazonq/rules/problem-creation.md @@ -42,15 +42,224 @@ Required fields for `leetcode_py/cli/resources/leetcode/json/problems/{problem_n - `playground_assertion`: Use single quotes for string literals - Double quotes in JSON + cookiecutter + Jupyter notebook = triple escaping issues -**Reference the complete template example:** - -See `leetcode_py/cli/resources/leetcode/examples/example.json5` for a comprehensive template with: - -- All field definitions and variations -- Comments explaining each field -- Examples for different problem types (basic, tree, linked list, design, trie) -- Proper JSON escaping rules for playground fields -- Multiple solution class patterns +**IMPORTANT: Create actual JSON files, not JSON5** + +The template below uses JSON5 format with comments for documentation purposes only. When creating the actual `.json` file, you must: + +1. **Remove all comments** (lines starting with `//`) +2. **Use proper JSON syntax** with quoted property names +3. **Save as `.json` file** (not `.json5`) + +**Template with comments (JSON5 format for reference only):** + +````json5 +{ + // ============================================================================ + // COMPREHENSIVE LEETCODE TEMPLATE EXAMPLE + // ============================================================================ + // This example demonstrates ALL template patterns using valid_anagram as base + // with comprehensive comments showing variations for different problem types. + // + // REFERENCE PROBLEMS (see .templates/leetcode/json/ for complete examples): + // 1. valid_anagram - Basic: string parameters, boolean return + // 2. invert_binary_tree - Tree: TreeNode imports/parameters + // 3. merge_two_sorted_lists - LinkedList: ListNode imports/parameters + // 4. lru_cache - Design: custom class, multiple methods, operations + // 5. implement_trie_prefix_tree - Trie: DictTree inheritance + // ============================================================================ + + // === PROBLEM IDENTIFICATION === + problem_name: "valid_anagram", // snake_case: used for directory/file names + solution_class_name: "Solution", // "Solution" for basic problems + // "LRUCache" for design problems + // "Trie(DictTree[str])" for inheritance + problem_number: "242", // LeetCode problem number as string + problem_title: "Valid Anagram", // Exact title from LeetCode + difficulty: "Easy", // Easy, Medium, Hard + topics: "Hash Table, String, Sorting", // Comma-separated topics from LeetCode + _tags: { list: ["grind-75"] }, // Optional: common problem set tags + // Use _tags wrapper for cookiecutter lists + + // === README CONTENT === + // IMPORTANT: Preserve rich HTML content from LeetCode including: + // - Code snippets with backticks: `code` + // - Bold text: **bold** or bold + // - Italic text: *italic* or italic + // - Images: ![Example](https://assets.leetcode.com/uploads/...) + // - HTML formatting:

,
,