Word Problem Generator
Word Problem Generator System
17+ generator variations for creating customizable math word problems across all operations

What It Does


Why I Built This

Math word problems are essential for helping students connect abstract mathematical concepts to real-world scenarios. However, creating quality word problems is time-consuming for teachers. I recognized the opportunity to build a system that could generate contextually rich, mathematically accurate problems at scale.

What started as a simple addition generator evolved into a comprehensive system supporting 17+ variations across all basic operations. The goal was to give teachers a tool powerful enough to create differentiated instruction materials—easy problems for struggling students, challenging ones for advanced learners, and everything in between—all with a few clicks.


How It Works

The Word Problem Generator is built with React and uses a template-based system for creating problem variations. Each generator variation uses predefined problem templates with variable slots that get filled with randomly generated values constrained by difficulty settings and mathematical rules.

The system validates that generated problems are mathematically sound (no negative results in subtraction for beginners, appropriate dividend/divisor relationships for division, etc.) and formats answers consistently. The template system allows for rich contextual variety—problems about shopping, sports, cooking, and other relatable scenarios—while maintaining mathematical rigor.

A major architectural milestone was implementing the strategy pattern, which dramatically reduced the time needed to create new generator variations. What previously took weeks of development could be accomplished in days, allowing rapid expansion of the system to cover more operation types and difficulty levels.


Impact

By the numbers:

What changed:


Challenges & Solutions

Architectural Complexity: As the number of generator types grew, code duplication became a serious problem. Each new variation required duplicating core logic with minor tweaks. I solved this by implementing the strategy pattern, which separated the problem generation logic from the rendering system. This allowed generator variations to share common code while customizing only what made them unique.

Mathematical Validation: Different operation types have different constraints. Subtraction shouldn't produce negative numbers for young learners. Division needs appropriate divisor selection to avoid impossible problems. I built a flexible validation system that could enforce operation-specific rules while maintaining code reusability.

Template Design: Creating word problems that feel natural and contextually appropriate while maintaining mathematical flexibility was challenging. I developed a template system that used realistic scenarios with variable slots, ensuring problems were both educationally sound and engaging for students.

Testing at Scale: With 17+ variations, manual testing became impractical. I refactored the test suite into a batch-type execution system, allowing comprehensive testing across all variations with minimal manual effort. This was essential for maintaining quality as the system scaled.


What I Learned

This project taught me the value of stepping back to improve architecture before pushing forward with more features. The strategy pattern refactor felt like it was slowing down progress initially, but it was one of the best investments I made. That week of refactoring saved months of development time across the remaining variations.

I also learned about the importance of designing for extensibility from the start. Early generator versions were tightly coupled, making each new variation a full reimplementation. By separating concerns—problem generation from rendering, validation from template logic—I created a system that could grow efficiently.

Technical skills developed:

Project evolution:


Technical Highlights

Strategy Pattern Implementation: The biggest technical milestone was refactoring the generator core to use the strategy pattern. This allowed pluggable problem-generation logic with minimal code changes, reducing new variation development time by approximately 60%.

Factory Pattern Separation: In September 2023, I refactored the Word Problem Factory to separate from the rendering model. This architectural improvement improved memory efficiency through better enumeration usage and positioned the system for future multi-render capabilities.

Batch Testing System: Created a comprehensive testing framework that could execute tests across all generator variations automatically, catching edge cases and ensuring mathematical accuracy at scale.

Dependency Injection Improvements: Refactored the dependency injection system to allow generator variations to share code more effectively while maintaining flexibility for customization.


Generator Variations Published

Addition Generators:

Subtraction Generators:

Multiplication Generators:

Division Generators:

Mixed Operations:


Links