Created
December 6, 2012 22:31
-
-
Save shannah/4229088 to your computer and use it in GitHub Desktop.
Revised Towers of Hanoi Benchmark with static variable that is incremented.
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
#import "com_mycompany_myapp_NativeTowersOfHanoiImpl.h" | |
static counter = 0; | |
void com_mycompany_myapp_NativeTowersOfHanoiImpl_move(int n, int startPole, int endPole) { | |
if (n == 0) { | |
return; | |
} | |
int intermediatePole = 6 - startPole - endPole; | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(n - 1, startPole, intermediatePole); | |
//NSLog(@"Move %i from %i to %i", n, startPole, endPole); | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(n - 1, intermediatePole, endPole); | |
counter++; | |
} | |
@implementation com_mycompany_myapp_NativeTowersOfHanoiImpl | |
-(int)runCalculation{ | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(30, 1, 3); | |
return counter; | |
} | |
-(BOOL)isSupported{ | |
return YES; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment