Dynamic programming

From rnavarych/alpha-engineer · View interactive version

Dynamic programming is an AI agent skill from the GitHub repository rnavarych/alpha-engineer. Solves optimization problems using dynamic programming — top-down memoization, bottom-up tabulation, state space design, dimension reduction, bitmask DP, interval DP, tree DP (with rerooting), DP on DAGs, and convex hull trick / divide-and-conquer optimizations. Use when solving optimization problem

How to use this skill

Skill file

Dynamic Programming

When to use

Core principles

  1. State captures everything — if future decisions need more information, the state is incomplete
  2. Bottom-up for production — no stack overflow, easier space optimization, predictable memory access
  3. Rolling array before adding a dimension — space optimization is almost always possible
  4. Bitmask DP is exact exponential, not a hack — O(2^n × n) is acceptable for n ≤ 20
  5. Identify the DAG — every DP is a shortest/longest path on a state DAG; if you can draw it, you can implement it

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.