Skip to content

Instantly share code, notes, and snippets.

@shannah
Created December 6, 2012 22:33
Show Gist options
  • Save shannah/4229097 to your computer and use it in GitHub Desktop.
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.
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