Created
December 6, 2012 22:33
-
-
Save shannah/4229097 to your computer and use it in GitHub Desktop.
Towers Of Hanoi class used for benchmarking CodenameOne revised with static variable incrementing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.myapp; | |
public class TowersOfHanoi { | |
public static int counter = 0; | |
public static void move(int n, int startPole, int endPole) { | |
if (n == 0) { | |
return; | |
} | |
int intermediatePole = 6 - startPole - endPole; | |
move(n - 1, startPole, intermediatePole); | |
move(n - 1, intermediatePole, endPole); | |
counter++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment