-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolver.cs
39 lines (34 loc) · 951 Bytes
/
Solver.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
using System;
namespace Sudoko_Solver
{
static class Solver
{
internal static void updateBoard(NumBox obj)
{
foreach (NumBox e in MainWindow.numBoxes)
{
if (e.valueSet)
continue;
if (e.Column == obj.Column || e.Row == obj.Row || e.Region == obj.Region)
{
int value = Convert.ToInt32(obj.Text);
if (value <= 0)
throw new IndexOutOfRangeException();
e.removeValue(value - 1);
}
}
}
public static void solve()
{
foreach (NumBox e in MainWindow.numBoxes)
{
e.IsReadOnly = true;
if (e.Text != "")
{
e.valueSet = true;
updateBoard(e);
}
}
}
}
}