I am writing a program for a Sudoku puzzle using Constraint Satisfaction. I have created a 2D vector to store the domains of possible values:
vector<vector<int>> domains;
The 2D vector is in a struct.
Long story short, the domains are filled with 0 values, and I need to remove any instance of the elements that are equal to 0. How do I remove an element in a 2D array?
The 9 is because there is a maximum number of 9 values that can be stored as domain values, 1-9 (possible Sudoku values). I suppose I could have the limit be the size of mainBoard.domains[i].size(). Let me see what happens, or if it succeeds, when I delete the beginning element.
Yes but why are you using this constant in a for() loop that removes elements? If you erase one elements you will only have 8 elements in the vector. If you then try to access the 9th element you will be accessing the vector out of range.