Consider the original tower of Hanoi problem with one extra condition :
- If you have 3 pole A , B and C you are not allowed to move a disc directly from A to B or B to A
that means from the famous recursive solution we are not allowed to move start to temp or temp to start.
void hanoi(int n, char start, char temp, char finish){
if (n== 1)
cout << start << " -> " << finish;
else {
hanoi(n - 1, start, finish, temp);
cout << start << " -> " << finish;
hanoi(n - 1, temp, start, finish);
}
}
Can anyone help me to find a solution for this ?