-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoreTest.cs
59 lines (50 loc) · 1.51 KB
/
CoreTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
class CoreTest
{
SuDoKu _sudoku;
Puzzler _puzzler;
int[,] _sudokuMatrix;
int[,] _sudokuPuzzle;
public void Init()
{
_sudoku = new SuDoKu();
_sudokuMatrix = _sudoku.GenerateSuDoKu();
_puzzler = new Puzzler();
_sudokuPuzzle =
_puzzler.GenerateSuDoKuPuzzle(_sudokuMatrix, Difficulty.EASY);
PrintMatrix(_sudokuMatrix);
PrintMatrix(_sudokuPuzzle);
}
public void PrintMatrix(int[,] matrix)
{
for (int i = matrix.GetLength(0) - 1; i >= 0; i--)
{
if (i % 3 == 2)
Console.WriteLine("+---------+---------+---------+");
for (int j = 0; j < matrix.GetLength(1); j++)
{
if (j % 3 == 0) Console.Write("|");
if (matrix[j, i] != 0)
Console.Write(" " + matrix[j, i] + " ");
else
Console.Write(" . ");
}
Console.WriteLine("|");
}
Console.WriteLine("+---------+---------+---------+");
}
void PrintRow(int[,] matrix, int rowIndex)
{
Console.WriteLine();
for (int i = 0; i < matrix.GetLength(0); i++)
Console.Write(" " + matrix[i, rowIndex] + " ");
Console.WriteLine();
}
void PrintCol(int[,] matrix, int colIndex)
{
Console.WriteLine();
for (int i = 0; i < matrix.GetLength(1); i++)
Console.Write(" " + matrix[colIndex, i] + " ");
Console.WriteLine();
}
}