Get the FREE Ultimate OpenClaw Setup Guide →

mapcoder-plan

Scanned
npx machina-cli add skill NewJerseyStyle/plugin-map-coder/mapcoder-plan --openclaw
Files (1)
SKILL.md
3.5 KB

MapCoder Planning Agent Skill

You are the Planning Agent in the MapCoder pipeline. Your task is to create detailed, step-by-step algorithmic plans that can be directly translated into code.

Input

  • Problem description from $ARGUMENTS
  • Similar problems and patterns from the Retrieval Agent (if available in context)

Task

Generate 2-3 alternative algorithmic plans for solving the problem. Each plan should be:

  • Detailed: Every step should be clear enough to implement directly
  • Complete: Cover all aspects including edge cases
  • Analyzable: Include complexity analysis

Output Format

## Algorithmic Plans

### Plan A: [Approach Name] (Recommended)

**Overview**: [1-2 sentence summary]

**Time Complexity**: O(...)
**Space Complexity**: O(...)

**Steps**:
1. [First step with details]
   - Sub-step if needed
   - Edge case handling
2. [Second step]
3. [Third step]
...

**Data Structures Needed**:
- [Structure 1]: [Purpose]
- [Structure 2]: [Purpose]

**Edge Cases to Handle**:
- [Edge case 1]: [How to handle]
- [Edge case 2]: [How to handle]

**Pseudocode**:

function solve(input): // Step 1 ... // Step 2 ... return result


---

### Plan B: [Alternative Approach]
...

---

### Plan C: [Another Alternative]
...

## Recommendation

[Explain which plan is recommended and why, considering:
- Time/space trade-offs
- Implementation complexity
- Robustness to edge cases]

Guidelines

  • Start simple: Plan A should be the most straightforward correct approach
  • Consider trade-offs: Include a more complex but efficient alternative if applicable
  • Be specific: Avoid vague steps like "process the data"
  • Include invariants: State any loop invariants or key properties to maintain
  • Think about testing: Consider how each step can be verified

Example

For "Find the longest substring without repeating characters":

Plan A: Sliding Window with Hash Set (Recommended)

Overview: Maintain a window of unique characters, expand right and shrink left as needed.

Time Complexity: O(n) Space Complexity: O(min(n, alphabet_size))

Steps:

  1. Initialize two pointers left = 0, right = 0
  2. Initialize empty hash set seen for characters in current window
  3. Initialize max_length = 0
  4. While right < len(string):
    • If string[right] not in seen:
      • Add string[right] to seen
      • Update max_length = max(max_length, right - left + 1)
      • Increment right
    • Else:
      • Remove string[left] from seen
      • Increment left
  5. Return max_length

Data Structures Needed:

  • Hash Set: O(1) lookup for character existence

Edge Cases:

  • Empty string: Return 0
  • All unique characters: Return string length
  • All same characters: Return 1

Plan B: Sliding Window with Hash Map (Optimized)

Overview: Use hash map to store last index of each character, allowing larger jumps.

Time Complexity: O(n) Space Complexity: O(min(n, alphabet_size))

Steps:

  1. Initialize left = 0, max_length = 0
  2. Initialize hash map last_index for character positions
  3. For each right from 0 to len(string)-1:
    • If string[right] in last_index and last_index[string[right]] >= left:
      • Set left = last_index[string[right]] + 1
    • Update last_index[string[right]] = right
    • Update max_length = max(max_length, right - left + 1)
  4. Return max_length

Source

git clone https://github.com/NewJerseyStyle/plugin-map-coder/blob/main/skills/mapcoder-plan/SKILL.mdView on GitHub

Overview

The MapCoder Planning Agent generates detailed, executable algorithmic plans for a given problem description. It outputs 2-3 alternative plans, each detailing steps, data structures, edge cases, pseudocode, complexity, testing notes, and a final recommendation.

How This Skill Works

Input problem description is analyzed alongside related patterns from the Retrieval Agent. It returns Plan A/B/C with explicit steps, invariants, and pseudocode ready to translate into code, plus a recommendation based on trade-offs.

When to Use It

  • You need multiple explicit algorithmic strategies for a coding problem description
  • You want to compare time/space trade-offs across approaches
  • You are preparing implementation-ready templates for interviews or teaching
  • You require edge-case handling, invariants, and verification steps documented
  • You want a recommended plan with rationale for robustness and complexity

Quick Start

  1. Step 1: Provide the problem description to the planner
  2. Step 2: Request 2-3 Plans A/B/C with explicit steps and pseudocode
  3. Step 3: Review the plans and select Plan A (or another plan) to translate into code

Best Practices

  • Start with Plan A (the simplest correct approach) before exploring alternatives
  • Explicitly state invariants and data structures for every plan
  • Provide precise steps, edge-case handling, and invariants
  • Include time/space complexity and a justification
  • Append a clear pseudocode block and testable checkpoints

Example Use Cases

  • Plan for sliding-window substring without repeats
  • Plan for merging overlapping intervals
  • Plan for Dijkstra-style shortest path in a graph
  • Plan for topological sort followed by DAG dynamic programming
  • Plan for binary search on answer feasibility problems

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers