sudoku prog problem

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
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";
            else if (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.
Last edited on
seeplus,
When I clicked on that link, I got a 404. Are you sure about that? The OP's profile says that he only has one post.
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.
The post was removed.
@function0353,
A word of advice: Don't double post. People might think you're spamming, and they may report you.

Sorry I can't help you, but I am still trying to relearn vectors myself; anything I say would be guessing.
got it thanks for the heads up.
does anyone have any idea how i can go about figuring this out? thank you
Do you have a whole program or do you just have the function?
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
I did get the inf2 working somewhat to where the values are being removed but its not there all the way, would love if any one has any input.
its submitted already, i couldn't get it to work properly.
Topic archived. No new replies allowed.