main_templates4/knight1.scala
changeset 400 bf47dbac07f8
parent 397 9755af1d74df
child 425 6e990ae2c6a3
equal deleted inserted replaced
399:d04b8569f124 400:bf47dbac07f8
     2 //==========================================
     2 //==========================================
     3 
     3 
     4 
     4 
     5 object M4a {
     5 object M4a {
     6 
     6 
     7 // If you need any auxiliary function, feel free to 
     7 // If you need any auxiliary functions, feel free to 
     8 // implement it, but do not make any changes to the
     8 // implement them, but do not make any changes to the
     9 // templates below. Also have a look whether the functions
     9 // templates below. Also have a look whether the functions
    10 // at the end are of any help.
    10 // at the end of the file are of any help.
    11 
    11 
    12 
    12 
    13 
    13 
    14 type Pos = (Int, Int)    // a position on a chessboard 
    14 type Pos = (Int, Int)    // a position on a chessboard 
    15 type Path = List[Pos]    // a path...a list of positions
    15 type Path = List[Pos]    // a path...a list of positions
    83   println(f"Time needed: ${(end - start) / 1.0e9}%3.3f secs.")
    83   println(f"Time needed: ${(end - start) / 1.0e9}%3.3f secs.")
    84   result
    84   result
    85 }
    85 }
    86 
    86 
    87 // can be called for example with
    87 // can be called for example with
       
    88 //
    88 //     time_needed(count_tours(dim, List((0, 0))))
    89 //     time_needed(count_tours(dim, List((0, 0))))
       
    90 //
    89 // in order to print out the time that is needed for 
    91 // in order to print out the time that is needed for 
    90 // running count_tours
    92 // running count_tours
    91 
    93 
    92 
    94 
    93 // for printing a board
    95 // for printing a board