package ch.zhaw.ads;

public class HanoiServer implements CommandExecutor {

    @Override
    public String execute(String command) {
        int n = Integer.parseInt(command);
        return moveDisk(n, 'A', 'B', 'C');
    }

    public String moveDisk(int n, char from, char to, char help) {
        String out = "";
        if (n > 0) {
            // bewege Stapel n-1 von from auf help
            out += moveDisk(n-1, from, help, to);
            // bewege von from nach to
            out += "move " + from + " to " + to + "\n";
            // bewege Stapel n-1 von help auf to
            out += moveDisk(n-1, help, to, from);
        }
        return out;
    }
}
