X-Git-Url: http://git.euphorik.ch/?p=sudokuSolver.git;a=blobdiff_plain;f=SudokuSolver%2FProgram.fs;h=b45930ffe6b84917050a7c91d1e127e2593c4ecc;hp=3402bc5474b069655e897634ae98e7d7e0bc83c5;hb=0434576455bb0eb8b7593c892d69fe0cf63a6b20;hpb=93c2731de053d0698800eb8a7ba1a475a38e58cc diff --git a/SudokuSolver/Program.fs b/SudokuSolver/Program.fs index 3402bc5..b45930f 100644 --- a/SudokuSolver/Program.fs +++ b/SudokuSolver/Program.fs @@ -5,24 +5,37 @@ module Solver = Version1 open System open System.IO -[] -let main argv = - use fs = new FileStream ("../../../sudokus/mm_22.txt", FileMode.Open, FileAccess.Read) - use sr = new StreamReader (fs) - - while sr.Peek () <> -1 do - let b = Solver.Board sr - b.Show System.Console.Out - - printfn "vvvvvvvvvvv" +let printUsage () = + printfn "Usage: %s " System.AppDomain.CurrentDomain.FriendlyName - let timer = System.Diagnostics.Stopwatch () - timer.Start () - - if b.Solve () - then b.Show System.Console.Out - else printfn "No solution" - - timer.Stop () - printfn "Time: %A ms" timer.ElapsedMilliseconds - 0 \ No newline at end of file +[] +let main args = + if args.Length = 0 then + GUI.showMainWindow () + 0 + elif Array.exists (fun arg -> arg = "-h" || arg = "--help") args then + printUsage () + 0 + else + for filepath in args do + use fs = new FileStream(filepath, FileMode.Open, FileAccess.Read) + use sr = new StreamReader(fs) + + printfn "%s" filepath + while sr.Peek() <> -1 do + let b = Solver.Board sr + b.Show System.Console.Out + + printfn "vvvvvvvvvvv" + + let timer = System.Diagnostics.Stopwatch() + timer.Start() + + if b.Solve () + then b.Show System.Console.Out + else printfn "No solution" + + timer.Stop() + printfn "Time: %A ms" timer.ElapsedMilliseconds + printfn "" + 0 \ No newline at end of file