Files
gastown/.beads/formulas/towers-of-hanoi.formula.json
Steve Yegge 0984914ae1 Convert formula files from YAML to JSON (gt-mdgt8)
All 9 formula files converted:
- shiny, rule-of-five, security-audit, shiny-enterprise
- towers-of-hanoi
- mol-deacon-patrol, mol-refinery-patrol, mol-witness-patrol, mol-polecat-arm

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 01:48:01 -08:00

55 lines
2.1 KiB
JSON

{
"formula": "towers-of-hanoi",
"description": "Solve Towers of Hanoi for {disks} disks. Generates 2^{disks} - 1 steps, each a trivial move operation. Demonstrates mechanical structure generation for arbitrarily long workflows.",
"version": 1,
"vars": {
"disks": "{{disks}}",
"source_peg": "A",
"target_peg": "C",
"auxiliary_peg": "B"
},
"generate": {
"for-each": {
"var": "move_num",
"range": "1..2^{disks}"
},
"step": {
"id": "move-{move_num}",
"description": "Move {computed_disk} from {computed_source} to {computed_target}. This is move {move_num} of {total_moves}. Simply execute the move - no decision needed.",
"needs": ["move-{move_num - 1}"],
"compute": {
"disk": "lowest_set_bit({move_num})",
"source": "peg_for_disk({disk}, {move_num}, 'source')",
"target": "peg_for_disk({disk}, {move_num}, 'target')"
}
}
},
"steps": [
{
"id": "setup",
"description": "Verify initial state: {disks} disks stacked on peg {source_peg}. All disks in order (largest on bottom)."
},
{
"id": "solve",
"description": "Execute all {total_moves} moves to transfer tower from {source_peg} to {target_peg}.",
"needs": ["setup"]
},
{
"id": "verify",
"description": "Verify final state: all {disks} disks now on peg {target_peg}. Tower intact, all moves were legal.",
"needs": ["solve"]
}
],
"example_3_disk": {
"steps": [
{"id": "move-1", "description": "Move disk 1 from A to C"},
{"id": "move-2", "description": "Move disk 2 from A to B", "needs": ["move-1"]},
{"id": "move-3", "description": "Move disk 1 from C to B", "needs": ["move-2"]},
{"id": "move-4", "description": "Move disk 3 from A to C", "needs": ["move-3"]},
{"id": "move-5", "description": "Move disk 1 from B to A", "needs": ["move-4"]},
{"id": "move-6", "description": "Move disk 2 from B to C", "needs": ["move-5"]},
{"id": "move-7", "description": "Move disk 1 from A to C", "needs": ["move-6"]}
]
}
}