Created
February 14, 2011 12:16
-
-
Save brtzsnr/825795 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
int32_t Topswops::Evaluate() { | |
int8_t *temp = (int8_t *)malloc(size); | |
memcpy(temp, wops, size); | |
score = 0; | |
while (temp[0] != 1) { | |
score++; | |
Rotate(temp, 0, temp[0]); | |
} | |
free(temp); | |
return score; | |
} | |
void Rotate(int8_t *buff, int start, int end) { | |
buff += start; | |
int length = end - start; | |
for (int i = 0, j = length - 1; i < length / 2; i += 2, j -= 2) { | |
int8_t swp0 = buff[i + 0]; | |
int8_t swp1 = buff[i + 1]; | |
buff[i + 0] = buff[j - 0]; | |
buff[i + 1] = buff[j - 1]; | |
buff[j + 0] = swp0; | |
buff[j - 1] = swp1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment