equal
deleted
inserted
replaced
39 if (path.length == dim * dim) 1 |
39 if (path.length == dim * dim) 1 |
40 else |
40 else |
41 (for (x <- legal_moves(dim, path, path.head)) yield count_tours(dim, x::path)).sum |
41 (for (x <- legal_moves(dim, path, path.head)) yield count_tours(dim, x::path)).sum |
42 } |
42 } |
43 |
43 |
|
44 def count_tours(dim: Int, path : Path) : Int = { |
|
45 |
|
46 if (path.length == dim * dim) {1} |
|
47 else |
|
48 val x = for (m <- legal_moves(dim,path,path.head)) yield { |
|
49 |
|
50 count_tours(dim,m::path) |
|
51 } |
|
52 x.sum |
|
53 |
|
54 } |
|
55 |
44 def enum_tours(dim: Int, path: Path): List[Path] = { |
56 def enum_tours(dim: Int, path: Path): List[Path] = { |
45 if (path.length == dim * dim) List(path) |
57 if (path.length == dim * dim) List(path) |
46 else |
58 else |
47 (for (x <- legal_moves(dim, path, path.head)) yield enum_tours(dim, x::path)).flatten |
59 (for (x <- legal_moves(dim, path, path.head)) yield enum_tours(dim, x::path)).flatten |
48 } |
60 } |