progs/knight2_sol.scala
changeset 66 3506b681c191
parent 64 d6f97b562424
child 86 f8a781322499
equal deleted inserted replaced
65:f59e70e2ad82 66:3506b681c191
    41   if (path.length == dim * dim) Some(path)
    41   if (path.length == dim * dim) Some(path)
    42   else
    42   else
    43     first(legal_moves(dim, path, path.head), (x: Pos) => first_tour(dim, x::path))
    43     first(legal_moves(dim, path, path.head), (x: Pos) => first_tour(dim, x::path))
    44 }
    44 }
    45 
    45 
       
    46 /*
    46 for (dim <- 1 to 8) {
    47 for (dim <- 1 to 8) {
    47   val t = first_tour(dim, List((0, 0)))
    48   val t = first_tour(dim, List((0, 0)))
    48   println(s"${dim} x ${dim} " + (if (t == None) "" else { print_board(dim, t.get) ; "" }))
    49   println(s"${dim} x ${dim} " + (if (t == None) "" else { print_board(dim, t.get) ; "" }))
    49 }
    50 }
       
    51 */
    50  
    52  
       
    53 print_board(8, first_tour(8, List((0, 0))).get)
    51 
    54 
    52 
    55 
    53