public bool Solve(Board b) { depth++; b.GridsWithOnlyOnePossibility(); if (b.State == state.SOLVED) { Console.WriteLine("DONE!\n" + b.ToString()); //sw.Stop(); Console.WriteLine("depth - {0}", depth); //Console.WriteLine("time - {0}mSEC", sw.ElapsedMilliseconds); //Environment.Exit(0); return(true); } else { Grid g = minList(); if ((g == null) || (b.State == state.BAD)) { return(false); } foreach (int possibleValue in g.possibleValues) //state is VALID { Board newBoard = Board.Copy(b); newBoard.SetGridAndUpdateList(g.Row, g.Col, possibleValue); newBoard.GridsWithOnlyOnePossibility();////////// if (newBoard.Solve(newBoard) == true) { break; } } } return(false); }