diff -r 3f34da7a3094 -r 12dc251fc47e templates3/knight1.scala --- a/templates3/knight1.scala Thu Oct 31 09:49:33 2019 +0000 +++ b/templates3/knight1.scala Thu Oct 31 10:44:10 2019 +0000 @@ -1,5 +1,8 @@ -// Part 1 about finding Knight's tours -//===================================== +// Preliminary Part about finding Knight's tours +//=============================================== + + +object CW8a { // If you need any auxiliary function, feel free to // implement it, but do not make any changes to the @@ -26,7 +29,7 @@ //def legal_moves(dim: Int, path: Path, x: Pos) : List[Pos] = ... -//some test cases +//some testcases // //assert(legal_moves(8, Nil, (2,2)) == // List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))) @@ -46,7 +49,7 @@ //def enum_tours(dim: Int, path: Path) : List[Path] = ... -//(5) Implement a first-function that finds the first +//(4) Implement a first-function that finds the first // element, say x, in the list xs where f is not None. // In that case Return f(x), otherwise None. If possible, // calculate f(x) only once. @@ -54,16 +57,15 @@ //def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ... -// test cases +// testcases +// //def foo(x: (Int, Int)) = if (x._1 > 3) Some(List(x)) else None // //first(List((1, 0),(2, 0),(3, 0),(4, 0)), foo) // Some(List((4,0))) //first(List((1, 0),(2, 0),(3, 0)), foo) // None - - -//(6) Implement a function that uses the first-function from (5) for +//(5) Implement a function that uses the first-function from (5) for // trying out onward moves, and searches recursively for a // knight tour on a dim * dim-board. @@ -92,6 +94,9 @@ // in order to print out the time that is needed for // running count_tours + + + // for printing a board def print_board(dim: Int, path: Path): Unit = { println @@ -105,3 +110,5 @@ */ + +}