void sudoku::Inf2() {
cout << "sudoku::Inf2()" << endl;
for (int i = 0; i < 9; i++){
for(int j = 0; j < 9; j++){
//pair<int,int> cell = make_pair(i,j);//init
Number& number = dataNumber[i][j];
vector< vector< pair<int,int> > > setIndices = groupIndices(i, j);
for (int si = 0; si < setIndices.size(); si++){
string tag = "";
if (si == 0)
tag = "column";
elseif (si == 1)
tag = "row";
else
tag = "unit";
// cout << "si: " << si << " " << tag << " i= " << i << " j= " << j << endl;
vector< pair<int, int> > indices = setIndices[si];
//MATCHING SET TODO
vector< pair<int, int> > matchingSet;
for(int x = 0; x < indices.size(); x++){
pair<int, int> x_val = indices[x];
// cout << "(" << x_val.first << "," << x_val.second << ")";
//&& number.GetDomain() == dataNumber[x_val.first][x_val.second].GetDomain()
if(IsSubset(number.GetDomain(), dataNumber[x_val.first][x_val.second].GetDomain())){
cout << "at i= " << i << " j= " << j << "found subset with i= " << x_val.first << " j= " << x_val.second << endl;
matchingSet.push_back(make_pair(x_val.first, x_val.second));
}
}//x end
cout << "Size of matching set: " << matchingSet.size() << endl;
if (matchingSet.size() == number.GetDomain().size()-1){
cout << "Found domains set for Inf2" << endl;
//remove from numbers domain using loop
for(int r = 0; r < 9; r++){
pair<int, int> n_val = indices[r];
if(number.value == ;{
}
//use removefromdomain helper function
// cout << " found: " << *it << endl;
//outer
}
//do something
}
// Number& temp = dataNumber[i][j];
// if(number.GetDomain().capacity() == temp.GetDomain().capacity() || number.GetDomain().size() == temp.GetDomain().size()){
// cout << "i= " << i << "j= " << j << "has one domain" << endl;
// cout << "value should be: " << number.GetDomain()[0] << endl;
// }
// if(tag == "column"){
// cout << "same domain in column: " << x << " i: " << i << " j: " << j << "\n";
// //setIndices.push_back();
// //
// cout << "this will be removed: " << x_val.first << " " << x_val.second << endl;
// number.RemoveFromDomain(dataNumber[x_val.first][x_val.second].GetDomain());
// //number.RemoveFromDomain(x_val.second);
// UpdateDomain(i,j);
// }else if(tag == "row"){
// cout << "same domain in row: " << x << " i: " << i << " j: " << j << "\n";
// setIndices.pop_back();
// }else
// cout << "same domain in unit: " << x << " i: " << i << " j: " << j << "\n";
}//inner
}//outer
}
Can any one help me figure out how i can: // TODO: Inf2 will try to find like domains and remove those values from other's domains.
I have tried the above but im lost on how to go about removing those values from others domains. I would appreciate anything to guide me in the right direction.
seeplus is right, i deleted that post this morning. I didnt know if it was ok to post in another forum since i never got a response in the beginner forum.
i have the whole program but i didnt think it was a good idea to post the whole thing as its 1.) kind of lengthy 2.) i dont want to put my solution to the first part that i solved already ... but what i posted is almost there, i just need to figure out how to remove the values from all the other domains that i found already
There is a helper function that takes an int value to remove it from the domain, and so i did: if(number.GetDomain() == VectortoInt(matchingSet.at(0)))
however that wont work, complier throws error: no suitable user defined conversion