equal
deleted
inserted
replaced
50 (get_col(game, pos._1) ++ get_row(game, pos._2) ++ get_box(game, pos)) |
50 (get_col(game, pos._1) ++ get_row(game, pos._2) ++ get_box(game, pos)) |
51 |
51 |
52 def candidates(game: String, pos: Pos): List[Char] = |
52 def candidates(game: String, pos: Pos): List[Char] = |
53 allValues.diff(toAvoid(game, pos)) |
53 allValues.diff(toAvoid(game, pos)) |
54 |
54 |
|
55 |
55 def search(game: String): List[String] = { |
56 def search(game: String): List[String] = { |
56 if (isDone(game)) List(game) |
57 if (isDone(game)) List(game) |
57 else |
58 else |
58 candidates(game, emptyPosition(game)).par. |
59 candidates(game, emptyPosition(game)).par. |
59 map(c => search(update(game, empty(game), c))).toList.flatten |
60 map(c => search(update(game, empty(game), c))).toList.flatten |
60 } |
61 } |
|
62 |
|
63 |
61 |
64 |
62 def search1T(games: List[String]): Option[String] = games match { |
65 def search1T(games: List[String]): Option[String] = games match { |
63 case Nil => None |
66 case Nil => None |
64 case game::rest => { |
67 case game::rest => { |
65 if (isDone(game)) Some(game) |
68 if (isDone(game)) Some(game) |
199 (end - start) / i / 1.0e9 |
202 (end - start) / i / 1.0e9 |
200 } |
203 } |
201 |
204 |
202 |
205 |
203 val total = |
206 val total = |
204 (for ((game, i) <- hard_games.zipWithIndex.par) yield { |
207 (for ((game, i) <- hard_games.zipWithIndex) yield { |
205 val secs = time_needed(1, search(game)) |
208 val secs = time_needed(1, search(game)) |
206 println(f"${i}%2.0f: ${game} |${secs}%2.3f secs") |
209 println(f"${i}%2.0f: ${game} |${secs}%2.3f secs") |
207 secs |
210 secs |
208 }).sum |
211 }).sum |
209 |
212 |