Write a PHP script to implement the Tower of Hanoi algorithm recursively.
MediumProblem Statement
Write a PHP script to implement the Tower of Hanoi algorithm recursively.
Sample Input
3 disks
Sample Output
Move disk 1 from A to C Move disk 2 from A to B Move disk 1 from C to B Move disk 3 from A to C Move disk 1 from B to A Move disk 2 from B to C Move disk 1 from A to C
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
<?php function towerOfHanoi($n, $from, $to, $aux) { // Your code here } ?>
Input
3 disks
Expected Output
Move disk 1 from A to C Move disk 2 from A to B Move disk 1 from C to B Move disk 3 from A to C Move disk 1 from B to A Move disk 2 from B to C Move disk 1 from A to C