Sudoku: Difference between revisions
Content added Content deleted
Line 4,198: | Line 4,198: | ||
| Some values -> values |> Map.toSeq |> Seq.map (snd>>string) |> String.concat "" |
| Some values -> values |> Map.toSeq |> Seq.map (snd>>string) |> String.concat "" |
||
| _ -> error |
| _ -> error |
||
/// Using depth-first search and propagation, try all possible values. |
/// Using depth-first search and propagation, try all possible values. |
||
let rec search (values:Map<_,_>) = |
let rec search (values:Map<_,_>) = |
||
Line 4,217: | Line 4,218: | ||
/// Solve Sudoku using Constraint Propagation |
/// Solve Sudoku using Constraint Propagation |
||
let solve grid = grid |> applyCPS >>= search |> prettyPrint</lang> |
let solve grid = grid |> applyCPS >>= search |> prettyPrint</lang> |
||
Usage<lang fsharp>open System |
'''Usage'''<lang fsharp>open System |
||
open SudokuCPS |
open SudokuCPS |
||
Line 4,308: | Line 4,309: | ||
Press any key to exit</pre> |
Press any key to exit</pre> |
||
===The Function SLPsolve=== |
===The Function SLPsolve=== |
||
<lang fsharp> |
<lang fsharp> |