progs/knight.scala
changeset 2 e0ec73c462c7
parent 1 b595d654cb2d
child 3 575a5c07c7fe
equal deleted inserted replaced
1:b595d654cb2d 2:e0ec73c462c7
    24 
    24 
    25 def tour(n: Int)(steps: List[(Int, Int)]): Unit = {
    25 def tour(n: Int)(steps: List[(Int, Int)]): Unit = {
    26   if (steps.length ==  n * n && moves(n)(steps.head).contains(steps.last))
    26   if (steps.length ==  n * n && moves(n)(steps.head).contains(steps.last))
    27     print_board(n)(steps)
    27     print_board(n)(steps)
    28   else 
    28   else 
    29     for (x <- moves(n)(steps.head).par; if (!steps.contains(x))) tour(n)(x :: steps)
    29     for (x <- moves(n)(steps.head); if (!steps.contains(x))) tour(n)(x :: steps)
    30 }
    30 }
    31 
    31 
    32 val n = 6
    32 val n = 6
    33 
    33 
    34 println("started")
    34 println("started")