Skip to content

Instantly share code, notes, and snippets.

@slg123
Created April 3, 2016 20:41
Show Gist options
  • Save slg123/cbaf1b8ab5eff862f8996656e728d621 to your computer and use it in GitHub Desktop.
Save slg123/cbaf1b8ab5eff862f8996656e728d621 to your computer and use it in GitHub Desktop.
void walk_board(int a[N][N]) {
knight_move moves[] = { 1,2, 2,1, 1,-2, 2,-1, -1,2, -2,1, -1,-2, -2,-1 };
int x = 1;
int y = 1;
int m = 1;
while (m <= 64) {
for (int i=0; i<sizeof(moves)/sizeof(moves[0]); i++) {
x = x+moves[i].x;
y = y+moves[i].y;
a[x][y] = m;
m++;
print_board(a);
}
}
}
@slg123
Copy link
Author

slg123 commented Apr 3, 2016

getting close to a knights tour in c. my knight just hangs out on the left side of the board, but the moves are working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment