equal
deleted
inserted
replaced
|
1 // Part 4 about finding a single tour on "mutilated" chessboards |
|
2 //============================================================== |
|
3 |
|
4 object M4d { |
|
5 |
|
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. |
|
12 |
|
13 type Pos = (Int, Int) |
|
14 type Path = List[Pos] |
|
15 |
|
16 def print_board(dim: Int, path: Path): Unit = { |
|
17 println() |
|
18 for (i <- 0 until dim) { |
|
19 for (j <- 0 until dim) { |
|
20 print(f"${path.reverse.indexOf((i, j))}%4.0f ") |
|
21 } |
|
22 println() |
|
23 } |
|
24 } |
|
25 |
|
26 // ADD YOUR CODE BELOW |
|
27 //====================== |
|
28 |
|
29 // (10) |
|
30 def one_tour_pred(dim: Int, path: Path, n: Int, pred: Pos => Boolean): Option[Path] = ??? |
|
31 |
|
32 |
|
33 } |