mapcoder-retrieve
npx machina-cli add skill NewJerseyStyle/plugin-map-coder/mapcoder-retrieve --openclawMapCoder Retrieval Agent Skill
You are the Retrieval Agent in the MapCoder pipeline. Your task is to generate K similar problems from your knowledge that can help solve the given problem.
Input
The problem description is provided in $ARGUMENTS.
Task
Generate 3-5 similar problems that share algorithmic or structural similarities with the input problem. For each similar problem:
- Problem Statement: A brief description of the similar problem
- Solution Pattern: The algorithmic approach used to solve it
- Key Insight: The critical observation that makes the solution work
- Relevance: Why this problem is relevant to the target problem
Output Format
## Similar Problems Retrieved
### Problem 1: [Problem Name]
**Statement**: [Brief problem description]
**Pattern**: [Algorithm/data structure used]
**Key Insight**: [Critical observation]
**Relevance**: [Why it helps with the target problem]
**Example Solution Sketch**:
[Pseudocode or brief algorithm]
### Problem 2: [Problem Name]
...
### Problem 3: [Problem Name]
...
Guidelines
- Focus on algorithmic similarity, not just surface-level keyword matching
- Include problems from diverse categories (arrays, trees, graphs, DP, etc.) if applicable
- Prioritize problems with well-known efficient solutions
- Include both classic CS problems and practical programming scenarios
- Consider edge cases and constraints that might be similar
Example
For problem "Find two numbers that sum to target":
Problem 1: Two Sum (Classic)
Statement: Given an array of integers and a target sum, find two numbers that add up to the target. Pattern: Hash map for O(1) complement lookup Key Insight: For each number x, check if (target - x) exists in seen numbers Relevance: Direct match - same problem structure
Problem 2: Three Sum
Statement: Find all unique triplets that sum to zero Pattern: Sort + two pointers, or hash map approach Key Insight: Reduce to Two Sum by fixing one element Relevance: Shows how Two Sum is a building block for larger problems
Problem 3: Pair with Given Difference
Statement: Find pair of elements with given difference Pattern: Hash map or two pointers on sorted array Key Insight: Similar complement search: look for (x + diff) instead of (target - x) Relevance: Same hash map pattern with different arithmetic operation
Source
git clone https://github.com/NewJerseyStyle/plugin-map-coder/blob/main/skills/mapcoder-retrieve/SKILL.mdView on GitHub Overview
The MapCoder Retrieval Agent Skill generates 3-5 problems similar in algorithmic or structural pattern to the given input problem. It helps developers recognize common templates and craft robust solutions by studying analogous tasks. This aids in building reusable solution templates across diverse domains.
How This Skill Works
Given the target problem description, the agent identifies key algorithmic motifs and data structures, then outputs 3-5 analogous problems. Each entry includes a brief statement, the solution pattern, a key insight, and a relevance note, plus a concise solution sketch to illuminate the pattern.
When to Use It
- When facing a new problem, to discover recognizable patterns and template approaches.
- When building a reusable solution skeleton by aligning with known problem families (e.g., two-sum, DP, graphs).
- During learning of algorithmic motifs to reinforce pattern recognition.
- For interview prep to map unfamiliar tasks to familiar templates.
- When expanding your problem-solving toolkit across data structures and paradigms.
Quick Start
- Step 1: Provide the target problem description via ARGUMENTS.
- Step 2: The agent generates 3-5 similar problems with statements, patterns, insights, and relevance.
- Step 3: Review and select the most informative analog to guide your solution.
Best Practices
- Foster true algorithmic similarity, not just surface keyword matches.
- Diversify problems across arrays, trees, graphs, DP, and other paradigms.
- Favor well-known, efficient solution patterns with clear time/space bounds.
- Consider edge cases and constraints that resemble the target problem.
- Use the provided solution sketches as templates, not exact code to copy.
Example Use Cases
- Two Sum (Classic): Statement: Given an array and a target sum, find two numbers that add up to the target. Pattern: hash-map complement lookup. Key Insight: check target - x existence in seen. Relevance: direct building block for related problems.
- Three Sum: Statement: Find all unique triplets that sum to zero. Pattern: sort + two-pointer. Key Insight: fix one element and reduce to Two Sum. Relevance: extends building blocks for larger problems.
- Pair with Given Difference: Statement: Find pair of elements with a given difference. Pattern: hash map or two pointers on sorted array. Key Insight: look for x + diff or x - diff. Relevance: similar complement search with a different arithmetic operation.
- Longest Increasing Subsequence (LIS): Statement: Find length of LIS in an array. Pattern: DP with binary search (patience sorting). Key Insight: track tails and use lower_bound. Relevance: demonstrates pattern recognition for sequences and state transitions.
- Clone Graph: Statement: Clone an undirected graph. Pattern: DFS/BFS with visitation map. Key Insight: maintain mapping to clone nodes; avoid cycles. Relevance: shows graph traversal and structure reasoning.