why does it load wrong[0] twice before loading wrong[1] ???

exactly what the title says.... basically this function goes through 81 boxes or 9 rows of 9 boxes. each box has "possibilities" so that box could look like 1256 or 13689 or etc. so i want it to go through each 9 boxes in the row and check if for example the numbers 2 and 9 are in 2 boxes in that row. if its in 3 or more boxes in that row, skip number. if the current box being tested doesnt have both numbers, then it gets loaded into the first empty wrong variable.. when i get to the end of the row, there should be 7 wrong and 2 right (box1 and box2).. if not then move on to the next number. so if 21 then move onto 23..(no doubles); if reached the end of the row and wrong[6] != null and box2 != null then change those two boxes to the number pair(num1 and num2 or just number) and remove theese two numbers from all the boxes that were wrong in this row.... kinda complicated but its coming along.. just this one little problem thats DRIVING ME INSANE :) btw refreshrows just sets the correct values to row based on s(row#)

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:;
		}
	}
}
Last edited on
Topic archived. No new replies allowed.