Jump to content

Sudoku: Difference between revisions

1,012 bytes added ,  2 years ago
m
Line 1,910:
}</lang>
Usage
<lang csharp>using System.Linq;
using static System.Linq.Enumerable;
using static System.Console;
using System.IO;
namespace Sudoku {
 
static class Program {
namespace SudokuSodukoFastMemoBFS {
static void Main(string[] args) {
static class Program {
//https://staffhome.ecm.uwa.edu.au/~00013890/sudoku17 format
 
var puzzle = "000028000800010000000000700000600403200004000100700000030400500000000010060000000";
static void Main(string[] args) {
WriteLine(Sudoku.Run(puzzle).AsString());
Readvar num = int.Parse(args[0]);
var puzzles = File.ReadLines(@"sudoku17.txt").Take(num);
}
var single = puzzles.First();
}
 
var watch = new System.Diagnostics.Stopwatch();
watch.Start();
WriteLine(SudokuSudokuFastMemoBFS.Run(puzzlesingle).AsString());
watch.Stop();
WriteLine($"{single}: {watch.ElapsedMilliseconds} ms");
 
WriteLine($"Doing {num} puzzles");
var total = 0.0;
watch.Start();
foreach (var puzzle in puzzles) {
watch.Reset();
watch.Start();
SudokuFastMemoBFS.Run(puzzle);
watch.Stop();
total += watch.ElapsedMilliseconds;
Write(".");
}
watch.Stop();
WriteLine($"\nPuzzles:{num}, Total:{total} ms, Average:{total / num:0.00} ms");
ReadKey();
}
}
}</lang>
Output
<pre>
693784512
617328945
487512936
894517236
125963874
325946781
932651487
978651423
568247391
256834179
741398625
143792658
319475268
731489562
856129743
489265317
274836159
562173894
000000010400000000020000000000050407008000300001090000300400200050100000000806000: 165 ms
</pre>
Doing 100 puzzles
....................................................................................................
Puzzles:100, Total:6131 ms, Average:61.31 ms</pre>
 
===“Automatic” Solution===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.