Esempio n. 1
0
 private static void WritePuzzle(string filePath, SudokuPuzzle sp, bool writeHtml = true)
 {
     using (StreamWriter sr = new StreamWriter(filePath))
     {
         sr.Write((writeHtml)?sp.ToHTMLString():sp.ToString());
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            SudokuPuzzle sp = new SudokuPuzzle();

            //sp.Populate(getSolution(true));
            //sp.Populate(GetPuzzle(10));
            sp = new SudokuPuzzle(SudokuPuzzle.GetPuzzle(@".\Boards\GEOboard.csv"));

            Console.WriteLine(sp.ToString());
            //WritePuzzle(@"K:\MyStuff\Documents\Personal\Sudoku\Output.txt", sp, false);
            WritePuzzle(@".\Output.html", sp);
            Console.ReadLine();
        }
Esempio n. 3
0
        public void Test_DoubleValueColumn()
        {
            SudokuPuzzle puzzle = new SudokuPuzzle();

            puzzle.Cells[0, 1].SetPossibleValues(new[] { 2, 9 });
            puzzle.Cells[0, 2].SetPossibleValues(new[] { 2, 9 });
            foreach (SudokuCell cell in puzzle.GetsSudokuSet(0, SudokuSetType.Column))
            {
                if (cell.X == 0 && (cell.Y == 1 || cell.Y == 2))
                {
                    continue;
                }
                Assert.IsFalse(cell.IsPossible(2), "Cell {0},{1} is not correct: {2}", cell.X, cell.Y, string.Join(",", cell.PossibleValues));
                Assert.IsFalse(cell.IsPossible(9), "Cell {0},{1} is not correct: {2}", cell.X, cell.Y, string.Join(",", cell.PossibleValues));
            }
            string teststr = puzzle.ToString();
        }