public static KenKen CreateKenKen() { KenKen kenKen = new KenKen(); kenKen.AddBlock(new int[] { 0, 0, 1, 0 }, 1, Operator.Subtract) .AddBlock(new int[] { 2, 0, 2, 1 }, 2, Operator.Divide) .AddBlock(new int[] { 3, 0, 3, 1 }, 6, Operator.Add) .AddBlock(new int[] { 4, 0, 5, 0 }, 20, Operator.Multiply) .AddBlock(new int[] { 0, 1, 1, 1 }, 3, Operator.Divide) .AddBlock(new int[] { 4, 1, 5, 1, 4, 2 }, 12, Operator.Multiply) .AddBlock(new int[] { 0, 2, 1, 2 }, 9, Operator.Add) .AddBlock(new int[] { 2, 2, 3, 2 }, 1, Operator.Subtract) .AddBlock(new int[] { 5, 2, 5, 3, 5, 4 }, 9, Operator.Add) .AddBlock(new int[] { 0, 3, 0, 4 }, 3, Operator.Divide) .AddBlock(new int[] { 1, 3, 1, 4 }, 10, Operator.Add) .AddBlock(new int[] { 2, 3, 2, 4 }, 1, Operator.Subtract) .AddBlock(new int[] { 3, 3, 4, 3, 3, 4 }, 90, Operator.Multiply) .AddBlock(new int[] { 0, 5, 1, 5, 2, 5 }, 8, Operator.Add) .AddBlock(new int[] { 4, 4, 3, 5, 4, 5, 5, 5 }, 144, Operator.Multiply); return(kenKen); }
static void Main(string[] args) { Stopwatch sw = new Stopwatch(); Sudoku wikipediaSudoku = CreateWikipediaSudoku(); System.Console.WriteLine("Sudoku from the Wikipedia page https://en.wikipedia.org/wiki/Sudoku"); Solver.Console.Show(wikipediaSudoku.Values); wikipediaSudoku.Solve(); Solver.Console.Show(wikipediaSudoku.Values); sw.Reset(); sw.Start(); Killer wikipediaKiller = CreateWikipediaKiller(); System.Console.WriteLine("Killer from the Wikipedia page https://en.wikipedia.org/wiki/Killer_sudoku"); wikipediaKiller.Solve(); Solver.Console.Show(wikipediaKiller.Values); sw.Stop(); System.Console.WriteLine("Killer solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); sw.Reset(); sw.Start(); KenKen wikipediaKenKen = CreateWikipediaKenKen(); System.Console.WriteLine("KenKen from the Wikipedia page https://en.wikipedia.org/wiki/KenKen"); wikipediaKenKen.Solve(); Solver.Console.Show(wikipediaKenKen.Values); sw.Stop(); System.Console.WriteLine("KenKen solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); Futoshiki wikipediaFutoshiki = CreateWikipediaFutoshiki(); System.Console.WriteLine("Futoshiki from the Wikipedia page https://en.wikipedia.org/wiki/Futoshiki"); Solver.Console.Show(wikipediaFutoshiki.Values); wikipediaFutoshiki.Solve(); Solver.Console.Show(wikipediaFutoshiki.Values); sw.Reset(); sw.Start(); Kakuro wikipediaKakuro = CreateWikipediaKakuro(); System.Console.WriteLine("Kakuro from the Wikipedia page https://en.wikipedia.org/wiki/Kakuro"); wikipediaKakuro.Solve(); Solver.Console.Show(wikipediaKakuro.Values); sw.Stop(); System.Console.WriteLine("Kakuro solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); Sudoku sudoku = CreateSudoku1(); System.Console.WriteLine("Sudoku Mild No 9596 from the Times, 16th Jan 2018"); Solver.Console.Show(sudoku.Values); sudoku.Solve(); Solver.Console.Show(sudoku.Values); Sudoku sudoku2 = CreateSudoku2(); System.Console.WriteLine("Sudoku Difficult No 9597 from the Times, 16th Jan 2018"); Solver.Console.Show(sudoku2.Values); sudoku2.Solve(); Solver.Console.Show(sudoku2.Values); Sudoku sudoku3 = CreateSudoku3(); System.Console.WriteLine("Sudoku Super fiendish No 9598 from the Times, 16th Jan 2018"); Solver.Console.Show(sudoku3.Values); sudoku3.Solve(); Solver.Console.Show(sudoku3.Values); sw.Reset(); sw.Start(); Killer killer = CreateKiller(); System.Console.WriteLine("Killer Tough No 5820 from the Times, 16th Jan 2018"); killer.Solve(); Solver.Console.Show(killer.Values); sw.Stop(); System.Console.WriteLine("Killer solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); sw.Reset(); sw.Start(); KenKen kenKen = CreateKenKen(); System.Console.WriteLine("KenKen Medium No 4226 from the Times, 16th Jan 2018"); kenKen.Solve(); Solver.Console.Show(kenKen.Values); sw.Stop(); System.Console.WriteLine("KenKen solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); Futoshiki futoshiki = CreateFutoshiki(); System.Console.WriteLine("Futoshiki No 3087 from the Times, 16th Jan 2018"); Solver.Console.Show(futoshiki.Values); futoshiki.Solve(); Solver.Console.Show(futoshiki.Values); sw.Reset(); sw.Start(); Kakuro kakuro = CreateKakuro(); System.Console.WriteLine("Kakuro No 2046 from the Times, 16th Jan 2018"); kakuro.Solve(); Solver.Console.Show(kakuro.Values); sw.Stop(); System.Console.WriteLine("Kakuro solution took " + sw.ElapsedMilliseconds / 1000.0 + " seconds"); System.Console.WriteLine(); System.Console.ReadLine(); }