progs/knight2_sol.scala
changeset 50 9891c9fac37e
parent 45 8399976b77fe
child 64 d6f97b562424
equal deleted inserted replaced
49:fdc2c6fb7a24 50:9891c9fac37e
     1 // Part 2 about finding a single tour for a board
     1 // Part 2 about finding a single tour for a board
     2 //================================================
     2 //================================================
     3 
     3 
     4 
     4 type Pos = (Int, Int)    // a position on a chessboard 
     5 type Pos = (Int, Int)
     5 type Path = List[Pos]    // a path...a list of positions
     6 type Path = List[Pos]
       
     7 
     6 
     8 def print_board(dim: Int, path: Path): Unit = {
     7 def print_board(dim: Int, path: Path): Unit = {
     9   println
     8   println
    10   for (i <- 0 until dim) {
     9   for (i <- 0 until dim) {
    11     for (j <- 0 until dim) {
    10     for (j <- 0 until dim) {