-int solve (int n) {
- // return the number of solutions to the n-queens problem
- int c = 0;
- int res = 0;
-
- row = (void *)malloc(sizeof(*row) * n);
- row[0] = -1;
- while (c >= 0) {
- row[c] = row[c]+1;
- while ((row[c] < n) && (!place_ok(c))) {
- row[c] = row[c]+1;
- }
- printf("RC: %d\n", row[c]);
- if (row[c] < n) { // successfully placed at (c,row[c])
- if (c == n-1)
- res = res+1;
- else {
- c = c+1;
- row[c] = -1;
- }
- }
- else // dead end, track back
- c = c-1;
- }
- free(row);
-
- return(res);
+static int solve (int n) {
+ // return the number of solutions to the n-queens problem
+ int c = 0;
+ int res = 0;
+
+ row = (void *)malloc(sizeof(*row) * n);
+ row[0] = -1;
+ while (c >= 0) {
+ row[c] = row[c]+1;
+ while ((row[c] < n) && (!place_ok(c))) {
+ row[c] = row[c]+1;
+ }
+ if (row[c] < n) { // successfully placed at (c,row[c])
+ if (c == n-1)
+ res = res+1;
+ else {
+ c = c+1;
+ row[c] = -1;
+ }
+ }
+ else // dead end, track back
+ c = c-1;
+ }
+ free(row);
+
+ return(res);