private void findPossibleAnswers() { //update the blank coordinates table _puzzleObject.UpdateCoordinates(); _blankCoordinates = _puzzleObject.FindTrueCoordinateTable(); //get a list of available numbers for the sqaure foreach (int[] xyCoords in _blankCoordinates) { // find all the possible numbers that could go there List <int> possibleCanidates = new List <int>(); for (int i = 1; i < _puzzleSize + 1; i++) { possibleCanidates.Add(i); } //starting at my x and y coordinates int x = xyCoords[0]; int y = xyCoords[1]; // check every other column in the row besides itself for (int col = 0; col < _puzzleSize; col++) { if (possibleCanidates.Contains(_puzzleObject._puzzle[x, col])) { possibleCanidates.Remove(_puzzleObject._puzzle[x, col]); } } //check every row at the column besides itself for (int row = 0; row < _puzzleSize; row++) { if (possibleCanidates.Contains(_puzzleObject._puzzle[row, y])) { possibleCanidates.Remove(_puzzleObject._puzzle[row, y]); } } // check the box... List <int[]> checkTheseBoxPositions = new List <int[]>(); // this contains a list of 4 coordiates to check checkTheseBoxPositions = whichBoxCoords(xyCoords); foreach (int[] position in checkTheseBoxPositions) { if (possibleCanidates.Contains(_puzzleObject._puzzle[position[0], position[1]])) { //remove this value from the possible canidates list possibleCanidates.Remove(_puzzleObject._puzzle[position[0], position[1]]); } } SingleCanidate singleCanidate = new SingleCanidate(xyCoords, possibleCanidates); _canidateList.Add(singleCanidate); } }
public void LoadPencilMarks() { List <string[]> pencilMarksToLoad = new List <string[]>(); try { DataAccessor dataAccessor = new DataAccessor(); pencilMarksToLoad = dataAccessor.RetrievePencilMarks(); } catch (Exception ex) { throw new ApplicationException("Data not availiable.", ex); } if (pencilMarksToLoad != null) { foreach (string[] pm in pencilMarksToLoad) { int[] coords = new int[2]; List <int> marks = new List <int>(); //coords = pencilMarksToLoad[0]; string coordsString = pm[0]; // (int)Char.GetNumericValue(contentList[0]) coords[0] = (int)Char.GetNumericValue(coordsString[0]); coords[1] = (int)Char.GetNumericValue(coordsString[1]); //marks = pencilMarksToLoad[1]; foreach (char num in pm[1]) { marks.Add((int)Char.GetNumericValue(num)); } SingleCanidate pencilMark = new SingleCanidate(coords, marks); _canidateList.Add(pencilMark); } } }
public void AddCanidate(SingleCanidate canidate) { _canidateList.Add(canidate); }