430
|
1 |
// Part 4 about finding a single tour on "mutilated" chessboards
|
|
2 |
//==============================================================
|
|
3 |
|
|
4 |
object M4d {
|
213
|
5 |
|
430
|
6 |
// !!! Copy any function you need from file knight1.scala !!!
|
|
7 |
// !!! or knight2.scala or knight3.scala !!!
|
|
8 |
//
|
|
9 |
// If you need any auxiliary function, feel free to
|
|
10 |
// implement it, but do not make any changes to the
|
|
11 |
// templates below.
|
213
|
12 |
|
|
13 |
type Pos = (Int, Int)
|
|
14 |
type Path = List[Pos]
|
|
15 |
|
|
16 |
def print_board(dim: Int, path: Path): Unit = {
|
347
|
17 |
println()
|
213
|
18 |
for (i <- 0 until dim) {
|
|
19 |
for (j <- 0 until dim) {
|
|
20 |
print(f"${path.reverse.indexOf((i, j))}%4.0f ")
|
|
21 |
}
|
347
|
22 |
println()
|
213
|
23 |
}
|
|
24 |
}
|
|
25 |
|
430
|
26 |
// ADD YOUR CODE BELOW
|
|
27 |
//======================
|
213
|
28 |
|
430
|
29 |
// (10)
|
|
30 |
def one_tour_pred(dim: Int, path: Path, n: Int, pred: Pos => Boolean): Option[Path] = ???
|
213
|
31 |
|
|
32 |
|
|
33 |
}
|