testing2/knight1.scala
changeset 154 39c6b93718f0
parent 145 d306102fd33b
child 163 84917f2e16cd
--- a/testing2/knight1.scala	Thu Nov 23 10:56:47 2017 +0000
+++ b/testing2/knight1.scala	Fri Nov 24 01:26:01 2017 +0000
@@ -41,6 +41,18 @@
     (for (x <- legal_moves(dim, path, path.head)) yield count_tours(dim, x::path)).sum
 }
 
+def count_tours(dim: Int, path : Path) : Int = {
+  
+  if (path.length == dim * dim) {1}
+  else 
+  val x = for (m <- legal_moves(dim,path,path.head)) yield {
+    
+    count_tours(dim,m::path)
+  }
+  x.sum
+  
+}
+
 def enum_tours(dim: Int, path: Path): List[Path] = {
   if (path.length == dim * dim) List(path)
   else