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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
void CheckRows()
{
for (int s = 0; s < 9; s++) // s = row
{
RefreshRows(s);
for (int n = 10; n < 99; n++) // n = pair being tested
{
box1 = NULL, box2 = NULL;
wrong[0] = NULL, wrong[1] = NULL, wrong[2] = NULL, wrong[3] = NULL, wrong[4] = NULL, wrong[5] = NULL, wrong[6] = NULL;
oss << n;
number = oss.str();
oss.str("");
num1 = number.at(0);
num2 = number.at(1);
for (int p = 0; p < 9; p++) // p = box in row being tested
{
actualBox = p + (9 * s);
//if find same two numbers multiple times in row
if (std::count(row.begin(), row.end(), num1) > 1 && std::count(row.begin(), row.end(), num2) > 1 && num1 != num2)
{
if (checkBoxes[p].find(num1) != string::npos && checkBoxes[p].find(num2) != string::npos && boxes[actualBox] == NULL )
{
cout << "found # " << num1 << num2 << " in box " << actualBox << "\n";
system("PAUSE");
if (box1 == NULL)
{
box1 = actualBox;
}
else if (box2 == NULL)
{
box2 = actualBox;
cout << "box 2 filled\n";
}
else if (box2 != NULL)
{
goto skip1;
}
}
else if (wrong[0] == 0)
{
cout << "wrong0 = " << n << "\n";
wrong[0] = actualBox;
}
else if (wrong[1] == NULL)
{
cout << "wrong1\n";
wrong[1] = actualBox;
}
else if (wrong[2] == NULL)
{
cout << "wrong2\n";
wrong[2] = actualBox;
}
else if (wrong[3] == NULL)
{
cout << "wrong3\n";
wrong[3] = actualBox;
}
else if (wrong[4] == NULL)
{
cout << "wrong4\n";
wrong[4] = actualBox;
}
else if (wrong[5] == NULL)
{
cout << "wrong5\n";
wrong[5] = actualBox;
}
else if (wrong[6] == NULL)
{
cout << "wrong6\n";
wrong[6] = actualBox;
}
}
if (box2 != NULL && wrong[6] != NULL)
{
cout << "wrong[6] full and box2 full\n";
//change those two boxes to theese three possibilities
possible[box1] = doubles;
possible[box2] = doubles;
//remove theese three possibilities from other boxes in row
RemoveNumber(possible[wrong[0]], num1);
RemoveNumber(possible[wrong[0]], num2);
RemoveNumber(possible[wrong[1]], num1);
RemoveNumber(possible[wrong[1]], num2);
RemoveNumber(possible[wrong[2]], num1);
RemoveNumber(possible[wrong[2]], num2);
RemoveNumber(possible[wrong[3]], num1);
RemoveNumber(possible[wrong[3]], num2);
RemoveNumber(possible[wrong[4]], num1);
RemoveNumber(possible[wrong[4]], num2);
RemoveNumber(possible[wrong[5]], num1);
RemoveNumber(possible[wrong[5]], num2);
RemoveNumber(possible[wrong[6]], num1);
RemoveNumber(possible[wrong[6]], num2);
RefreshRows(s);
cout << "modified";
system("PAUSE");
}
}
skip1:;
}
}
}
|