简体   繁体   English

在C中的邻接矩阵中回溯?

[英]Backtracking in a adjacency matrix in C?

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. 我试图找到节点1和节点12之间的所有路径。唯一的限制是我不能多次遍历两个节点之间的任何路径。 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. 我需要考虑诸如1> 2> 5> 3> 2> 6> 8> 11> 12之类的路径,程序会在其中返回到节点。 The counter is just there to count the number of paths available (there should be 640 total paths, but I only have 16 paths). 计数器就是用来计算可用路径数的(总共应该有640条路径,但是我只有16条路径)。 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;
}

The biggest error was that your requirement is to visit each edge a maximum of once, but you were tracking nodes. 最大的错误是您的要求是每个边缘最多访问一次,但是您正在跟踪节点。

Also, I recommend always using {} braces after your if s, while s, etc. You have some misleading whitespace in your post. 另外,我建议始终在if s, while s等之后使用{}大括号。您的帖子中会有一些误导性的空格。

GCC 4.7.3: gcc -Wall -Wextra backtrace.c 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;
}

There was a previous version of this question as Finding all the paths in an adjacency matrix in C that has now been deleted by Ace (but 10K users can still see it). 这个问题的上一个版本是在C查找邻接矩阵中的所有路径,而Ace现在已经删除了该路径 (但是10K用户仍然可以看到它)。 It was the same problem, though. 不过,这是同样的问题。 Here's a different solution from Adam's, mainly posted because I'm stubborn and spent time on it. 这是与Adam的解决方案不同的解决方案,主要是因为我很固执并且花了很多时间在上面。 It finds the 640 solutions that were required. 它找到所需的640个解决方案。 It is more verbose than Adam's solution, but the issue fixed is the same — tracking the edges used rather than the nodes visited. 它比Adam的解决方案更为冗长,但是解决的问题是相同的–跟踪使用的边缘而不是所访问的节点。

It takes one command line option, -v , to be more verbose in its output (very verbose!). 它需要一个命令行选项-v ,使其输出更加详细(非常详细!)。 It prints the solutions forwards rather than backwards. 它打印解决方案是向前而不是向后。 It identifies the edges and reports the edges traversed in the output. 它标识边并报告输出中遍历的边。 It doesn't use global variables for the main data structures. 它不对主要数据结构使用全局变量。 I managed to go through some complex red herrings and I probably haven't removed everything. 我设法通过了一些复杂的红鲱鱼,我可能还没有删除所有内容。 Since some of the arrays are VLAs (variable length arrays), they cannot be initialized statically, so there are functions to do that initialization (not complex, just code — and yes, memset() could be used too or instead). 由于某些数组是VLA(可变长度数组),因此它们不能静态初始化,因此有一些函数可以进行初始化(不复杂,只需代码-是的,也可以使用memset()或代替)。 The chk_array_properties() function ensures that the array is symmetric and has zeros on the leading diagonal. chk_array_properties()函数可确保数组是对称的,并且前导对角线上为零。 The prt_links() function is not necessary; prt_links()函数; it gives a simple print of the connections in the matrix. 它给出了矩阵中连接的简单打印。

Network diagram 网络图

Time for some ASCII Art — what does the network really look like? 是时候学习一些ASCII艺术了-网络真的是什么样子? (Transferred from my previous answer.) (从我之前的回答中转移过来。)

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

Allowing for revisiting a node N as long as you do not enter from a node (along an edge) that was already used to get to N, and therefore leaving N to a node not already used to get from N, there is some possibility of there being 640 paths in this matrix. 只要您不从已经用于到达N的节点(沿着边缘)进入,就允许重新访问节点N,因此将N留给尚未用于从N获取的节点,此矩阵中有640条路径。

For example, if you're allowed to visit a node several times by different paths, then you can have: 例如,如果允许您通过不同的路径多次访问节点,那么您可以:

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

The longest paths seem to be of length 16 (2 hops longer than the full path above). 最长的路径似乎长度为16(比上面的完整路径长2跳)。 Of course, there are many permutations of those paths. 当然,这些路径有许多排列。 The distribution of the lengths (number of nodes visited) is: 长度的分布(访问的节点数)为:

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

Code

#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;
}

Partial output 部分输出

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM