Skip to content

Conversation

@vizahat36
Copy link
Contributor

Add Tower of Hanoi recursive algorithm

Description

Fixes #7223 (requested by @justanothercoder-hub).

This PR adds a professional, well-documented implementation of the Tower of Hanoi problem to the recursion module.
The solution demonstrates the classic recursive 3-step approach and adheres to all core problem constraints.

Features

  • Recursive implementation following standard Tower of Hanoi rules
  • Clear and educational JavaDoc documentation
  • Time complexity: O(2^n − 1), Space complexity: O(n)
  • JUnit test class added to validate the implementation

Testing

  • JUnit tests included
  • 25 test cases covering:
    • Disk count validation
    • Correctness of generated moves
    • Edge cases and exception handling
    • Formula verification (2^n − 1 moves)
  • All tests pass successfully
  • Checkstyle compliant

TowerOfHonai-output

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.11%. Comparing base (0f9139d) to head (fedf135).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7235   +/-   ##
=========================================
  Coverage     79.10%   79.11%           
- Complexity     6973     6979    +6     
=========================================
  Files           783      784    +1     
  Lines         22950    22965   +15     
  Branches       4512     4512           
=========================================
+ Hits          18154    18168   +14     
  Misses         4076     4076           
- Partials        720      721    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vizahat36
Copy link
Contributor Author

Hi @DenizAltunkapan,
This PR is ready for review and all CI checks are passing.
I’ve addressed the requested enhancement by adding the Tower of Hanoi implementation with documentation and JUnit tests.
Please check this once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Adding "TOWER OF HANOI" to Recursion File

2 participants