--- a/progs/lecture4.scala Fri Dec 02 07:48:03 2022 +0000
+++ b/progs/lecture4.scala Fri Dec 02 11:05:41 2022 +0000
@@ -280,7 +280,7 @@
// Tail recursion
//================
-def fact(n: BigInt): BigInt =
+def fact(n: Int): Int =
if (n == 0) 1 else n * fact(n - 1)
--- a/progs/sudoku.scala Fri Dec 02 07:48:03 2022 +0000
+++ b/progs/sudoku.scala Fri Dec 02 11:05:41 2022 +0000
@@ -52,6 +52,7 @@
def candidates(game: String, pos: Pos): List[Char] =
allValues.diff(toAvoid(game, pos))
+
def search(game: String): List[String] = {
if (isDone(game)) List(game)
else
@@ -59,6 +60,8 @@
map(c => search(update(game, empty(game), c))).toList.flatten
}
+
+
def search1T(games: List[String]): Option[String] = games match {
case Nil => None
case game::rest => {
@@ -201,7 +204,7 @@
val total =
- (for ((game, i) <- hard_games.zipWithIndex.par) yield {
+ (for ((game, i) <- hard_games.zipWithIndex) yield {
val secs = time_needed(1, search(game))
println(f"${i}%2.0f: ${game} |${secs}%2.3f secs")
secs