Generate math cage puzzles
generate_math_cagesUse this when the user wants printable math cage puzzles (arithmetic cage puzzles, calculation sudoku-style grids with cages, math logic puzzles for a class) as a PDF with an answer key. Each grid from 4 x 4 to 9 x 9 uses the numbers 1 to N once per row and column; each cage shows a target and a sign. Put one object per puzzle in puzzles[] when they differ (size, operations, difficulty); for a set of the same kind, set count with size, operations and difficulty. Operations accept signs or words ("+ -", "add only", "all four", "no division"). A solver checks each puzzle for one solution. The PDF has 1, 2 or 4 puzzles per page on Letter or A4, an optional title and name line, and answer pages. Defaults: 1 medium 6 x 6 puzzle with all four operations, Letter, 1 per page, name line and answer key on. Does not solve a puzzle from a photo or make grids larger than 9 x 9.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | Starting seed; puzzle N uses seed + N - 1. Reuse it to reprint the same puzzles. Example: 2026 | |
| size | No | Grid size for all puzzles, 4 to 9 (default 6). Example: 5 | |
| count | No | How many puzzles when they are all the same kind (1 to 12, default 1). Example: 4 | |
| paper | No | letter (default, US 8.5 x 11 in) or a4. Example: a4 | |
| title | No | Title printed at the top of each page. Example: Friday Math Challenge | |
| puzzles | No | One object per puzzle when the puzzles differ, e.g. [{"size":4,"operations":"add only"},{"size":6,"difficulty":"hard"}]. Leave out and use count for a set of the same kind. Up to 12. | |
| per_page | No | Puzzles per printed page: 1 (default), 2 or 4. Example: 2 | |
| name_line | No | Print a Name and Date line on the puzzle pages (default true). Example: false | |
| answer_key | No | Add answer pages with the solved grids (default true). Example: true | |
| difficulty | No | Difficulty for all puzzles: easy, medium (default) or hard. Example: easy | |
| operations | No | Signs for all puzzles: + - x / (default all four), or words such as "addition and subtraction only", "no division". Example: "+ x" |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | ||
| notes | Yes | ||
| pages | Yes | ||
| paper | Yes | ||
| title | Yes | ||
| puzzles | Yes | ||
| per_page | Yes | ||
| downloads | Yes | ||
| name_line | Yes | ||
| answer_key | Yes | ||
| puzzle_count | No | ||
| all_one_solution | Yes |