Add a GUI. Use FAKE to manage the build and paket for dependencies.
[sudokuSolver.git] / SudokuSolver / Program.fs
1 module SudokuSolver.Main
2
3 module Solver = Version1
4
5 open System
6 open System.IO
7
8 let printUsage () =
9 printfn "Usage: %s <suduko file>" System.AppDomain.CurrentDomain.FriendlyName
10
11 [<EntryPoint>]
12 let main args =
13 if args.Length = 0 then
14 GUI.showMainWindow ()
15 0
16 elif Array.exists (fun arg -> arg = "-h" || arg = "--help") args then
17 printUsage ()
18 0
19 else
20 for filepath in args do
21 use fs = new FileStream(filepath, FileMode.Open, FileAccess.Read)
22 use sr = new StreamReader(fs)
23
24 printfn "%s" filepath
25 while sr.Peek() <> -1 do
26 let b = Solver.Board sr
27 b.Show System.Console.Out
28
29 printfn "vvvvvvvvvvv"
30
31 let timer = System.Diagnostics.Stopwatch()
32 timer.Start()
33
34 if b.Solve ()
35 then b.Show System.Console.Out
36 else printfn "No solution"
37
38 timer.Stop()
39 printfn "Time: %A ms" timer.ElapsedMilliseconds
40 printfn ""
41 0