Code-to-Math Problem Synthesizer
Feed a Python function and get back a set of math olympiad-style problems whose solutions require understanding that function’s logic.
Difficulty: weekend | Stack: Python, Claude API (claude-sonnet), Streamlit, SymPy (optional, for answer verification)
Who this is for
Coding bootcamp instructors and competitive programming coaches who want algorithmically generated problem sets that test mathematical reasoning behind specific code patterns, not just rote syntax recall.
Build steps
- Build a Streamlit UI where users paste a Python function (sorting, dynamic programming, graph traversal, etc.).
- Send the function to Claude with a structured prompt: ‘Analyze this code’s mathematical behavior. Generate 3 problems a student must solve mathematically (no coding allowed) to predict its output on specific inputs or prove a property about it. Format each as: problem statement, constraints, expected answer, solution sketch.’
- Parse Claude’s response into a structured problem set (Pydantic model) and render each problem in an expandable card with a hidden solution reveal.
- Add a difficulty slider that instructs Claude to increase problem complexity — e.g., from ‘predict output for n=5’ to ‘prove time complexity’ to ‘derive recurrence relation’.
- Export the full problem set as a formatted PDF via WeasyPrint for classroom distribution.
Risks
- Claude occasionally generates problems with subtly wrong ‘expected answers,’ especially for edge-case-heavy functions — SymPy can verify numeric answers but symbolic proofs require manual spot-checking.
- The quality of generated problems degrades sharply for functions with heavy side effects or I/O — must pre-validate that input is a pure function and reject otherwise.
- Streamlit’s stateless architecture makes it awkward to maintain a session-level problem history; users lose generated sets on refresh unless you add explicit save-to-JSON functionality early.
Business Angle
Turn any Python function into a ready-to-assign math olympiad problem set in seconds — built for competitive programming coaches who hate writing problem sets from scratch.
Customer: Solo competitive programming coaches (USACO, Codeforces prep) who run 10–50-student cohorts online, charge $200–500/month per student, and currently spend 3–5 hours per week hand-crafting problems that test mathematical reasoning — not just coding syntax.
Pricing: saas-mrr — $500 MRR within 90 days (~17 paying coaches at $29/month)
Full business breakdown →