private bool CanConnectedColorReachCellInColumn(int rowIdx, int colIdx, ColorClassifier colCc) { var array = WorkingGrid.GetColumn(colIdx); var firstIndex = IndexOf(array, colCc.MyColor); var lastIndex = LastIndexOf(array, colCc.MyColor); if (firstIndex <= OutOfBoundsConst) { return(true); } if (firstIndex > rowIdx) { var minIdx = lastIndex - colCc.Count + 1; //3 if (rowIdx < minIdx) { return(false); } } else if (lastIndex < rowIdx) { var maxIdx = firstIndex + colCc.Count - 1; //5 if (rowIdx > maxIdx) { return(false); } } return(true); }
//Before refactor: Number of failing tests: 6 //Before refactor: Number of inconclusive tests: 280 private void Iterate(Selection selection) { SetupSelectionAndFields(selection); foreach (var item in _items) { _currentItem = item; foreach (var colorClassifierTemp in _currentItem.Colors) { _currentColor = colorClassifierTemp; foreach (var action in SolvePartActions) { if (SolvePart(action)) { break; } } } } }
private bool CanConnectedColorReachCellInRow(int rowIdx, int colIdx, ColorClassifier rowCc) { var array = WorkingGrid.GetRow(rowIdx); var firstIndex = IndexOf(array, rowCc.MyColor); var lastIndex = LastIndexOf(array, rowCc.MyColor); if (firstIndex <= OutOfBoundsConst) { return(true); } if (firstIndex > colIdx) { //a,_,_,_,b,_,_,_,_,a: "b" er connected, og Count = 2. //colIdx = 1 //firstIndex = 4 //lastIndex = 4 var minIdx = lastIndex - rowCc.Count + 1; //3 if (colIdx < minIdx) { return(false); } } else if (lastIndex < colIdx) { //a,a,a,_,b,_,_,_,_,a: "b" er connected, og Count = 2. //colIdx = 6 //firstIndex = 4 //lastIndex = 4 var maxIdx = firstIndex + rowCc.Count - 1; //5 if (colIdx > maxIdx) { return(false); } } return(true); }