--- a/progs/knight1_sol.scala Tue Nov 15 23:08:09 2016 +0000
+++ b/progs/knight1_sol.scala Wed Nov 16 14:37:18 2016 +0000
@@ -27,9 +27,12 @@
def legal_moves(dim: Int, path: Path, x: Pos): List[Pos] =
moves(x).filter(is_legal(dim, path))
-legal_moves(8, Nil, (2,2))
-legal_moves(8, Nil, (7,7))
-
+assert(legal_moves(8, Nil, (2,2)) ==
+ List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)))
+assert(legal_moves(8, Nil, (7,7)) == List((6,5), (5,6)))
+assert(legal_moves(8, List((4,1), (1,0)), (2,2)) ==
+ List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4)))
+assert(legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6)))
def count_tours(dim: Int, path: Path): Int = {
if (path.length == dim * dim) 1