SKILL.md
Create template for LeetCode problem $ARGUMENTS[0]
Instructions
- Determine the target folder. If a second argument was provided (
$ARGUMENTS[1]), use problems/$ARGUMENTS[1]/. Otherwise, place the file into problems/general/ subdirectory.
- Look up the problem. Use your training data to find LeetCode problem number $ARGUMENTS[0]. You need: the title, full description text, all examples (Input/Output/Explanation), all constraints, and any follow-up questions.
- Create the file at
problems/<topic>/problem_$ARGUMENTS[0].py following the exact skeleton below. Do not zero-pad the number.
- After creating the file, run
python -m pytest problems/<topic>/problem_$ARGUMENTS[0].py to confirm the tests are collected.
File skeleton
"""
$NUMBER. $TITLE
https://leetcode.com/problems/$SLUG/
$FULL_DESCRIPTION
Example 1:
$EXAMPLE_1
...
Constraints:
$CONSTRAINTS
"""
import pytest
class Solution:
def $METHOD_NAME(self, $PARAMETERS) -> $RETURN_TYPE: ...
@pytest.fixture
def sln():
yield Solution()
@pytest.mark.xfail(reason="Not implemented", strict=True)
def test_001(sln):
"""Test the first example from the problem description."""
assert sln.$METHOD_NAME($ARGS) == $EXPECTED
@pytest.mark.xfail(reason="Not implemented", strict=True)
def test_002(sln):
"""Test the second example from the problem description."""
assert sln.$METHOD_NAME($ARGS) == $EXPECTED
# Add more test functions for remaining examples.
Rules
- Import only
import pytest. Add additional imports from typing only if the method signature requires them (e.g. Optional, Dict).
- If the problem uses trees, also import
from treenode import TreeNode and use TreeNode.createfromlist() in tests.
- If the problem uses linked lists, also import
from linkedlists import ListNode, buildlinkedlist, linkedlisttolist and use those helpers in tests.
- The
Solution method body must be ... — never include an implementation.
- One
test_NNN(sln) per example, named sequentially. Each test has a short docstring. Do not use pytest.mark.parametrize.
- Every test must be decorated with
@pytest.mark.xfail(reason="Not implemented", strict=True). Remove the decorator once the solution is implemented.
- No
if name == "main" block.
- Match the style of
problems/backtracking/problem_79.py.