equal
  deleted
  inserted
  replaced
  
    
    
     1 // Part 2 about finding a single tour for a board  | 
         | 
     2 //================================================  | 
         | 
     3   | 
         | 
     4 // copy any function you need from file knight1.scala  | 
         | 
     5   | 
         | 
     6 object CW7b { | 
         | 
     7   | 
         | 
     8 type Pos = (Int, Int)    // a position on a chessboard   | 
         | 
     9 type Path = List[Pos]    // a path...a list of positions  | 
         | 
    10   | 
         | 
    11   | 
         | 
    12 //(2a) Implement a first-function that finds the first   | 
         | 
    13 //     element, say x, in the list xs where f is not None.   | 
         | 
    14 //     In that case Return f(x), otherwise None. If possible,  | 
         | 
    15 //     calculate f(x) only once.  | 
         | 
    16   | 
         | 
    17 //def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ...  | 
         | 
    18   | 
         | 
    19 //(2b) Implement a function that uses the first-function for  | 
         | 
    20 //     trying out onward moves, and searches recursively for a  | 
         | 
    21 //     knight tour on a dim * dim-board.  | 
         | 
    22   | 
         | 
    23 //def first_tour(dim: Int, path: Path) : Option[Path] = ...  | 
         | 
    24    | 
         | 
    25   | 
         | 
    26 }  | 
         |