Towers of Hanoi - Part 2 Comments
Comments
-
@Yogi, thanks for letting em know, it's been fixed.
-
Although I know the process of solution to the problem, I can't figure out how to transform into program. Could anyone give me some hint of how to program it?
-
You can view the beginning of a solution here. The comments there can help guide you to a full solution.
-
Thanks, I have finished the challenge with your hint.
-
public static void doStuff(int a){ solve(1, 3, a); System.out.println(); } static void solve(int a, int b, int elements){
if (elements == 1){ System.out.print(a + "->" + b + " "); } else { int intermediate = intermediate(a, b); solve(a, intermediate, elements - 1); solve(a,b,1); solve(intermediate, b, elements - 1); } } public static int intermediate(int from, int to){ return 6 - (from + to); }
Yogi
Jun 1, 1:50 AMWhy is my output shown as orange not green even though ouput matches.