aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/nqueens.c
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2010-05-03 09:25:43 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2010-05-03 09:25:43 -0300
commit9a50155ec3e27aa6cedf3f118196f1947c769a29 (patch)
treec23cc6949b227b9e09432af038a44ccb81d92ce6 /hardinfo2/nqueens.c
parentca5a3e84296a34c2391374942001cfaf1d8395a6 (diff)
Use CMake instead of ToscoConf.
Diffstat (limited to 'hardinfo2/nqueens.c')
-rw-r--r--hardinfo2/nqueens.c37
1 files changed, 0 insertions, 37 deletions
diff --git a/hardinfo2/nqueens.c b/hardinfo2/nqueens.c
deleted file mode 100644
index 838731c4..00000000
--- a/hardinfo2/nqueens.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * N-Queens Problem Solver
- * Found somewhere on the Internet; can't remember where. Possibly Wikipedia.
- */
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
-#define QUEENS 11
-
-int row[QUEENS];
-
-bool safe(int x, int y)
-{
- int i;
- for (i = 1; i <= y; i++)
- if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i)
- return false;
- return true;
-}
-
-int nqueens(int y)
-{
- int x;
-
- for (x = 0; x < QUEENS; x++) {
- if (safe((row[y - 1] = x), y - 1)) {
- if (y < QUEENS) {
- nqueens(y + 1);
- } else {
- break;
- }
- }
- }
-
- return 0;
-}