|         |      1  | 
|         |      2 //import scala.concurrent._ | 
|         |      3 //import scala.concurrent.duration._ | 
|         |      4 //import ExecutionContext.Implicits.global | 
|         |      5 //import scala.language.postfixOps  | 
|         |      6  | 
|         |      7 type Pos = (Int, Int) | 
|         |      8 type Path = List[Pos] | 
|         |      9  | 
|         |     10 def add_pair_urban(x: Pos)(y: Pos): Pos =  | 
|         |     11   (x._1 + y._1, x._2 + y._2) | 
|         |     12  | 
|         |     13 def is_legal_urban(dim: Int, path: Path)(x: Pos): Boolean =  | 
|         |     14   0 <= x._1 && 0 <= x._2 && x._1 < dim && x._2 < dim && !path.contains(x) | 
|         |     15  | 
|         |     16 def moves_urban(x: Pos): List[Pos] =  | 
|         |     17   List(( 1,  2),( 2,  1),( 2, -1),( 1, -2), | 
|         |     18        (-1, -2),(-2, -1),(-2,  1),(-1,  2)).map(add_pair_urban(x)) | 
|         |     19  | 
|         |     20 def legal_moves_urban(dim: Int, path: Path, x: Pos): List[Pos] =  | 
|         |     21   moves_urban(x).filter(is_legal_urban(dim, path)) | 
|         |     22  | 
|         |     23 def correct_urban(dim: Int)(p: Path): Boolean = p match { | 
|         |     24   case Nil => true | 
|         |     25   case x::Nil => true | 
|         |     26   case x::y::p =>  | 
|         |     27     if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false | 
|         |     28 } | 
|         |     29  | 
|         |     30 //lazy val f1 = Future { | 
|         |     31  | 
|         |     32   val ts8 = CW7c.first_tour_heuristic(8, List((0,0))).get | 
|         |     33   assert(correct_urban(8)(ts8) == true) | 
|         |     34  | 
|         |     35 //} | 
|         |     36  | 
|         |     37 //Await.result(f1, 360 second) | 
|         |     38  | 
|         |     39  | 
|         |     40 //lazy val f2 = Future { | 
|         |     41  | 
|         |     42   val ts40 = CW7c.first_tour_heuristic(40, List((0,0))).get | 
|         |     43   assert(correct_urban(40)(ts40) == true) | 
|         |     44  | 
|         |     45 //} | 
|         |     46  | 
|         |     47 //Await.result(f2, 360 second) |