Added Tower of Hanoi and Coin Change #12
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Included
1. New Algorithm Modules
algorithms/hanoi.typ
Formal recursive definition with binary branching structure.
Mapcode-style specification (rho, F, pi).
Concrete computation for a sample instance (3 disks, A→C using B).
Full state-space visualization using the project's mapcode-viz framework.
Structured layout for disk configurations, move sequences, and stepwise evaluation showing the two recursive subproblems per call.
algorithms/coinChange.typ
Formal DP recurrence definition with multi-way branching (one branch per coin).
Mapcode-style specification (rho, F, pi).
Concrete DP computation for a sample instance (amount=11, coins={1,3,4}).
Full DP-table visualization using the project's mapcode-viz framework.
Structured layout for amount-to-coins mapping, tensor updates, and stepwise evaluation demonstrating recursive branching.
2. Documentation Integration
Updated main.typ:
Added #include "algorithms/tower-of-hanoi.typ" after the existing algorithms section.
Added #include "algorithms/coin-change.typ" after the Tower of Hanoi section.
Ensures both chapters appear in output in correct sequence.
Why This Matters
Brings two classical recursive algorithms into the mapcode framework with distinct recursion patterns:
Tower of Hanoi: Binary recursion with two recursive calls per invocation
Coin Change: Multi-way branching with |coins| recursive calls per state
Demonstrates non-trivial recursion structures useful for debugging the mapcode-viz pipeline.
Provides examples of both divide-and-conquer (Hanoi) and dynamic programming (Coin Change) paradigms.
Serves as templates for future recursive algorithm additions.
Files Changed
algorithms/hanoi.typ — 138 lines added
algorithms/coinChange.typ — 119 lines added
main.typ — 4 lines added
No existing code modified; additions are isolated and non-breaking.
Checklist
✓ Builds successfully
✓ Renders correctly in main.typ
✓ Follows repository style and structure
✓ Demonstrates non-trivial recursion (≥2 branches)
✓ No backward-incompatible changes