<?php
# Author: Hannes du Plooy
# Date: 20 Sep 2016
# Objective: To solve the towers of hanoi with number of discs provided in the arguments to calling the program
function hanoi($source,$dest,$other,$discs) {
if ($discs > 0) {
hanoi($source,$other,$dest,$discs-1);
echo "Move $source to $dest\n";
hanoi($other,$dest,$source,$discs-1);
}
}
if (count($argv) < 2) {
echo "Please provide the number of discs!\n";
} else {
hanoi(0,2,1,intval($argv[1]));
}