1

I'm trying to find all the paths between node 1 and node 12. The only restriction is that I cannot traverse any path between two nodes more than once. Currently, my program just works in the forward direction. I need to consider paths such as 1 > 2 > 5 > 3 > 2 > 6 > 8 > 11 > 12, where the program travels back to a node. The counter is just there to count the number of paths available (there should be 640 total paths, but I only have 16 paths). This is what I have so far. Any ideas?

#include <stdio.h>

int edges[12][12] = {
    {0,1,0,0,0,0,0,0,0,0,0,0},
    {1,0,1,1,1,1,0,0,0,0,0,0},
    {0,1,0,0,1,0,0,0,0,0,0,0},
    {0,1,0,0,1,0,0,0,0,0,0,0},
    {0,1,1,1,0,0,1,1,0,0,0,0},
    {0,1,0,0,0,0,0,1,0,0,0,0},
    {0,0,0,0,1,0,0,0,0,0,1,0},
    {0,0,0,0,1,1,0,0,1,1,1,0},
    {0,0,0,0,0,0,0,1,0,0,1,0},
    {0,0,0,0,0,0,0,1,0,0,1,0},
    {0,0,0,0,0,0,1,1,1,1,0,1},
    {0,0,0,0,0,0,0,0,0,0,1,0}
};


int visited[12] = {0,0,0,0,0,0,0,0,0,0,0,0};

int counter = 0; 


struct Node {
    int node;
    struct Node *prev;
};


void visit (int node, struct Node *prev_node) { 
    struct Node n = { node, prev_node };
    struct Node *p = &n;
    if (node == 1){
        printf("%s", "1->");
    }
    if (node == 1){
        do 
            printf ("%d%s", p->node + 1, (p->prev != 0)?  "->" : "\n");
        while ((p = p->prev) != 0);
    }
    if (node == 1){
        counter++; 
        printf("%d\n", counter);
    }

    visited[node]=1;
    int i;
    for (i=0; i<12; ++i){
        if ((visited[i] == 0) && (edges[node][i] == 1))
            visit (i, &n);
            visited[node]=1;
    }
    visited[node]=0;

}


int main (int argc, char *argv[]) {

    int i;
    for (i=11; i<12; ++i) {
        visit (i, 0);
    }
    return 0;
}
4

2 回答 2

2

最大的错误是您的要求是最多访问每个边一次,但您正在跟踪节点。

另外,我建议始终在您的 s、s 等{}之后使用大括号。您的帖子中有一些误导性的空格。ifwhile

GCC 4.7.3:gcc -Wall -Wextra backtrace.c

#include <stdio.h>

int edges[12][12] = {
    {0,1,0,0,0,0,0,0,0,0,0,0},
    {1,0,1,1,1,1,0,0,0,0,0,0},
    {0,1,0,0,1,0,0,0,0,0,0,0},
    {0,1,0,0,1,0,0,0,0,0,0,0},
    {0,1,1,1,0,0,1,1,0,0,0,0},
    {0,1,0,0,0,0,0,1,0,0,0,0},
    {0,0,0,0,1,0,0,0,0,0,1,0},
    {0,0,0,0,1,1,0,0,1,1,1,0},
    {0,0,0,0,0,0,0,1,0,0,1,0},
    {0,0,0,0,0,0,0,1,0,0,1,0},
    {0,0,0,0,0,0,1,1,1,1,0,1},
    {0,0,0,0,0,0,0,0,0,0,1,0}
};

int visited[12][12] = {
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0}
};

int counter = 0;


struct Node {
    int node;
    struct Node *prev;
};

void print(struct Node* p) {
    do
        printf ("%d%s", p->node + 1, (p->prev != NULL)?  "<-" : "\n");
    while ((p = p->prev) != NULL);
    printf("%d\n", ++counter);
}

void flag(int i, int j) {
  visited[i][j] = visited[i][j] ? 0 : 1;
  visited[j][i] = visited[j][i] ? 0 : 1;
}

void visit (int first, int last, struct Node *prev_node) {
    struct Node n = { first, prev_node };

    if (first == last){ print(&n); return; }

    int i;
    for (i=0; i<12; ++i){
        if ((visited[first][i] == 0) && (edges[first][i] == 1)) {
            flag(first, i);
            visit(i, last, &n);
            flag(first, i);
        }
    }
}


int main (int argc, char *argv[]) {

    visit (0, 11, NULL);
    return 0;
}
于 2013-10-11T00:49:52.847 回答
0

这个问题的前一个版本是Find all the paths in an adjacency matrix in C in C,现在已被 Ace 删除(但 10K 用户仍然可以看到它)。不过,这是同样的问题。这是一个与亚当不同的解决方案,主要是因为我很固执并且花时间在上面。它会找到所需的 640 个解决方案。它比 Adam 的解决方案更冗长,但解决的问题是相同的——跟踪使用的边缘而不是访问的节点。

它需要一个命令行选项 ,-v在其输出中更详细(非常详细!)。它向前而不是向后打印解决方案。它识别边缘并报告输出中遍历的边缘。它不对主要数据结构使用全局变量。我设法通过了一些复杂的红鲱鱼,我可能还没有删除所有内容。由于一些数组是 VLA(可变长度数组),它们不能被静态初始化,所以有一些函数可以进行初始化(并不复杂,只是代码——是的,memset()也可以使用或代替)。该chk_array_properties()函数确保数组是对称的并且在前导对角线上有零。该prt_links()功能不是必需的;它给出了矩阵中连接的简单打印。

网络图

是时候学习一些 ASCII 艺术了——网络到底是什么样子的?(转自我之前的回答。)

         +------ 3 ---+
         |            |
         | +---- 4    |
         |/       \   |
1 ------ 2         \  |
         |\         \ |
         | +--------- 5 --------- 7 --------+ 
         |             \                    |
         |              \   +------------+  |
         |               \ /              \ |
         +------ 6 ------ 8 ------ 9 ------ 11 ------ 12
                           \                |
                            +----- 10 ------+

允许重新访问节点 N,只要您不从已经用于到达 N 的节点(沿边)进入,因此将 N 留给尚未用于从 N 获取的节点,有一些可能性该矩阵中有 640 条路径。

例如,如果允许您通过不同的路径多次访问一个节点,那么您可以:

1 ⟶ 2 ⟶ 4 ⟶ 5 ⟶ 3 ⟶ 2 ⟶ 6 ⟶ 8 ⟶ …
1 ⟶ 2 ⟶ 4 ⟶ 5 ⟶ 2 ⟶ 6 ⟶ 8 ⟶ …
1 ⟶ 2 ⟶ 3 ⟶ 5 ⟶ 2 ⟶ 6 ⟶ 8 ⟶ …
1 ⟶ 2 ⟶ 3 ⟶ 5 ⟶ 4 ⟶ 2 ⟶ 6 ⟶ 8 ⟶ …
1 ⟶ 2 ⟶ 6 ⟶ 8 ⟶ 5 ⟶ 3 ⟶ 2 ⟶ 4 ⟶ 5 ⟶ 7 ⟶ 11 ⟶ 8 ⟶ 10 ⟶ 11 ⟶ 12

最长的路径似乎长度为 16(比上面的完整路径长 2 跳)。当然,这些路径有许多排列。长度的分布(访问的节点数)为:

Length Number
  6    3
  7    8
  8    5
  9    8
 10   44
 11   56
 12   12
 13   48
 14  236
 15  176
 16   44

代码

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

struct Node
{
    int node;
    int edge;
    struct Node *prev;
};

static int vflag = 0;
static int num_solutions = 0;

static void prt_fwd_path_r(struct Node *p)
{
    char *pad = "";
    if (p->prev != NULL)
    {
        prt_fwd_path_r(p->prev);
        pad = " ->";
    }
    printf("%s N%d (E%d)", pad, p->node + 1, p->edge);
}

static void prt_fwd_path(struct Node *p)
{
    prt_fwd_path_r(p);
    putchar('\n');
}

static void visit2(int node, struct Node *prev_node, int size, int edges[size][size], int end, int *traversed)
{
    struct Node n = { node, 0, prev_node };
    struct Node *p = &n;

    if (vflag) printf("-->> %s (%d)\n", __func__, node);
    if (node == end)
    {
        printf("Solution %d: ", ++num_solutions);
        prt_fwd_path(p);
    }
    else
    {
        if (vflag) prt_fwd_path(p);
        for (int i = 0; i < size; ++i)
        {
            int e = edges[node][i];
            if (e != 0 && traversed[e] == 0)
            {
                traversed[e] = 1;
                n.edge = e;
                visit2(i, &n, size, edges, end, traversed);
                traversed[e] = 0;
            }
        }
    }
    if (vflag) printf("<<-- %s\n", __func__);
}

static void chk_array_properties(char const *tag, int n, int a[n][n])
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i][j] != a[j][i])
                fprintf(stderr, "Broken symmetry: %s[%d,%d] = %d, %s[%d,%d] = %d\n",
                        tag, i, j, a[i][j], tag, j, i, a[j][i]);
        }
        if (a[i][i] != 0)
            fprintf(stderr, "Non-zero leading diagonal: %s[%d][%d] == %d\n",
                    tag, i, i, a[i][i]);
    }
}

static void prt_links(int size, int edges[size][size])
{
    int edge_num = 0;
    for (int i = 0; i < size; i++)
    {
        for (int j = i; j < size; j++)
        {
            if (edges[i][j])
                printf("%2d: %d -> %d\n", ++edge_num, i+1, j+1);
        }
    }
}

static int count_edges(int size, int edges[size][size])
{
    int count = 0;
    for (int i = 0; i < size; i++)
    {
        for (int j = i; j < size; j++)
        {
            if (edges[i][j])
                count++;
        }
    }
    return count;
}

static void dump_array(char const *fmt, int size, int edges[size][size])
{
    for (int i = 0; i < size; i++)
    {
        for (int j = 0; j < size; j++)
            printf(fmt, edges[i][j]);
        putchar('\n');
    }
}

static void mark_matrix(int n, int paths[n][n], int nodes[n][n])
{
    int pathnum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            if (paths[i][j] == 0)
            {
                nodes[i][j] = 0;
                nodes[j][i] = 0;
            }
            else
            {
                pathnum++;
                nodes[i][j] = pathnum;
                nodes[j][i] = pathnum;
            }
        }
    }
}

static void zero_array(int n, int a[n][n])
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            a[i][j] = 0;
    }
}

static void zero_vector(int n, int v[n])
{
    for (int i = 0; i < n; i++)
        v[i] = 0;
}

static void usage(char const *arg0)
{
    fprintf(stderr, "Usage: %s [-v]\n", arg0);
    exit(1);
}

int main(int argc, char **argv)
{
    enum { N = 12 };
    int paths[N][N] =
    {
        {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
        {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
        {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
        {0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0},
        {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
        {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0},
        {0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0},
        {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0},
        {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0},
        {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}
    };
    int opt;

    while ((opt = getopt(argc, argv, "v")) != -1)
    {
        switch (opt)
        {
        case 'v':
            vflag = 1;
            break;
        default:
            usage(argv[0]);
            break;
        }
    }
    if (optind != argc)
        usage(argv[0]);
    puts("Connections:");
    dump_array(" %2d", N, paths);
    chk_array_properties("paths", N, paths);

    int matrix[N][N];
    int nedges = count_edges(N, paths);
    int edges[nedges + 1];
    zero_array(N, matrix);
    zero_vector(nedges + 1, edges);
    mark_matrix(N, paths, matrix);
    puts("Edges numbered:");
    dump_array(" %2d", N, matrix);
    chk_array_properties("matrix", N, matrix);
    puts("Edges enumerated:");
    prt_links(N, matrix);
    visit2(0, NULL, N, matrix, N-1, edges);
    printf("%d Solutions found\n", num_solutions);

    return 0;
}

部分输出

Connections:
  0  1  0  0  0  0  0  0  0  0  0  0
  1  0  1  1  1  1  0  0  0  0  0  0
  0  1  0  0  1  0  0  0  0  0  0  0
  0  1  0  0  1  0  0  0  0  0  0  0
  0  1  1  1  0  0  1  1  0  0  0  0
  0  1  0  0  0  0  0  1  0  0  0  0
  0  0  0  0  1  0  0  0  0  0  1  0
  0  0  0  0  1  1  0  0  1  1  1  0
  0  0  0  0  0  0  0  1  0  0  1  0
  0  0  0  0  0  0  0  1  0  0  1  0
  0  0  0  0  0  0  1  1  1  1  0  1
  0  0  0  0  0  0  0  0  0  0  1  0
Edges numbered:
  0  1  0  0  0  0  0  0  0  0  0  0
  1  0  2  3  4  5  0  0  0  0  0  0
  0  2  0  0  6  0  0  0  0  0  0  0
  0  3  0  0  7  0  0  0  0  0  0  0
  0  4  6  7  0  0  8  9  0  0  0  0
  0  5  0  0  0  0  0 10  0  0  0  0
  0  0  0  0  8  0  0  0  0  0 11  0
  0  0  0  0  9 10  0  0 12 13 14  0
  0  0  0  0  0  0  0 12  0  0 15  0
  0  0  0  0  0  0  0 13  0  0 16  0
  0  0  0  0  0  0 11 14 15 16  0 17
  0  0  0  0  0  0  0  0  0  0 17  0
Edges enumerated:
 1: 1 -> 2
 2: 2 -> 3
 3: 2 -> 4
 4: 2 -> 5
 5: 2 -> 6
 6: 3 -> 5
 7: 4 -> 5
 8: 5 -> 7
 9: 5 -> 8
10: 6 -> 8
11: 7 -> 11
12: 8 -> 9
13: 8 -> 10
14: 8 -> 11
15: 9 -> 11
16: 10 -> 11
17: 11 -> 12
Solution 1:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E14) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)
Solution 2:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E14) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 3:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E15) -> N9 (E12) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 4:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E15) -> N9 (E12) -> N8 (E14) -> N11 (E17) -> N12 (E0)
Solution 5:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E16) -> N10 (E13) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)
Solution 6:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E16) -> N10 (E13) -> N8 (E14) -> N11 (E17) -> N12 (E0)
Solution 7:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 8:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E12) -> N9 (E15) -> N11 (E14) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 9:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E12) -> N9 (E15) -> N11 (E16) -> N10 (E13) -> N8 (E14) -> N11 (E17) -> N12 (E0)
Solution 10:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)
Solution 11:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E13) -> N10 (E16) -> N11 (E14) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)
Solution 12:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E13) -> N10 (E16) -> N11 (E15) -> N9 (E12) -> N8 (E14) -> N11 (E17) -> N12 (E0)
Solution 13:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 14:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 15:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)
Solution 16:  N1 (E1) -> N2 (E2) -> N3 (E6) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E9) -> N8 (E14) -> N11 (E17) -> N12 (E0)
...
Solution 624:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E4) -> N2 (E2) -> N3 (E6) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 625:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 626:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E6) -> N3 (E2) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 627:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E6) -> N3 (E2) -> N2 (E4) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 628:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E7) -> N4 (E3) -> N2 (E2) -> N3 (E6) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 629:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E7) -> N4 (E3) -> N2 (E4) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 630:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E9) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 631:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E15) -> N9 (E12) -> N8 (E13) -> N10 (E16) -> N11 (E17) -> N12 (E0)
Solution 632:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E4) -> N2 (E2) -> N3 (E6) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 633:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E4) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 634:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E6) -> N3 (E2) -> N2 (E3) -> N4 (E7) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 635:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E6) -> N3 (E2) -> N2 (E4) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 636:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E7) -> N4 (E3) -> N2 (E2) -> N3 (E6) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 637:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E7) -> N4 (E3) -> N2 (E4) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 638:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E9) -> N5 (E8) -> N7 (E11) -> N11 (E17) -> N12 (E0)
Solution 639:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E16) -> N10 (E13) -> N8 (E12) -> N9 (E15) -> N11 (E17) -> N12 (E0)

Solution 640:  N1 (E1) -> N2 (E5) -> N6 (E10) -> N8 (E14) -> N11 (E17) -> N12 (E0)
640 Solutions found
于 2013-10-12T22:28:16.400 回答