templates3-bak/knight2.scala
changeset 202 f7bcb27d1940
parent 147 72f7dd1a3754
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates3-bak/knight2.scala	Thu Nov 15 03:35:38 2018 +0000
@@ -0,0 +1,26 @@
+// Part 2 about finding a single tour for a board
+//================================================
+
+// copy any function you need from file knight1.scala
+
+object CW7b {
+
+type Pos = (Int, Int)    // a position on a chessboard 
+type Path = List[Pos]    // a path...a list of positions
+
+
+//(2a) 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.
+
+//def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ...
+
+//(2b) Implement a function that uses the first-function for
+//     trying out onward moves, and searches recursively for a
+//     knight tour on a dim * dim-board.
+
+//def first_tour(dim: Int, path: Path) : Option[Path] = ...
+ 
+
+}