//
// main.cpp
// Tower of Hanoi
//
// Created by Himanshu on 05/04/22.
//
#include <iostream>
void towerOfHanoi (int n, char from, char to, char aux) {
if (n <= 0) {
return;
}
towerOfHanoi(n-1, from, aux, to);
printf("%c -> %c\n", from, to);
towerOfHanoi(n-1, aux, to, from);
}
int main () {
int n = 3;
towerOfHanoi(n, 'A', 'B', 'C');
return 0;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBUb3dlciBvZiBIYW5vaQovLwovLyAgQ3JlYXRlZCBieSBIaW1hbnNodSBvbiAwNS8wNC8yMi4KLy8KCiNpbmNsdWRlIDxpb3N0cmVhbT4KCnZvaWQgdG93ZXJPZkhhbm9pIChpbnQgbiwgY2hhciBmcm9tLCBjaGFyIHRvLCBjaGFyIGF1eCkgewogICAgaWYgKG4gPD0gMCkgewogICAgICAgIHJldHVybjsKICAgIH0KICAgIAogICAgdG93ZXJPZkhhbm9pKG4tMSwgZnJvbSwgYXV4LCB0byk7CiAgICBwcmludGYoIiVjIC0+ICVjXG4iLCBmcm9tLCB0byk7CiAgICB0b3dlck9mSGFub2kobi0xLCBhdXgsIHRvLCBmcm9tKTsKfQoKaW50IG1haW4gKCkgewogICAgaW50IG4gPSAzOwogICAgdG93ZXJPZkhhbm9pKG4sICdBJywgJ0InLCAnQycpOwogICAgcmV0dXJuIDA7Cn0K