public Solver(SudokuData sudokuData)
            {
                if (sudokuData == null)
                {
                    throw new ArgumentNullException("sudokuData");
                }
                this.sudokuData = sudokuData;

                var sudoku = new SudokuSolver.Definition.Sudoku();

                foreach (var grid in sudokuData.Grids)
                {
                    var sudokuGrid = sudoku.Grids[grid.Index];
                    foreach (var element in grid.Elements.Where(item => item.Value.HasValue))
                    {
                        sudokuGrid.Elements[element.Index].SetValue(element.Value.Value);
                    }
                }

                foreach (var element in new SudokuSolver.SudokuElementEnumerable(sudoku))
                {
                    element.ValueChanged += onElementValueChanged;
                }

                this.sudoku = sudoku;
            }
 public SudokuSolverWithSteps(SudokuData sudoku)
 {
     if (sudoku == null)
     {
         throw new ArgumentNullException("sudoku");
     }
     this.source = sudoku;
 }
Exemple #3
0
        public SudokuInputValidator(SudokuData sudoku)
        {
            if (sudoku == null)
            {
                throw new ArgumentNullException("sudoku");
            }
            this.sudoku = sudoku;

            foreach (var grid in sudoku.Grids)
            {
                foreach (INotifyPropertyChanged target in grid.Elements)
                {
                    target.PropertyChanged += onElementPropertyChanged;
                }
            }
        }
Exemple #4
0
        public SudokuData Copy()
        {
            var copy = new SudokuData();

            using (var elementIterator = copy.grids.SelectMany(item => item.Elements).GetEnumerator())
                using (var valueIterator = this.Values().GetEnumerator())
                {
                    while (elementIterator.MoveNext() && valueIterator.MoveNext())
                    {
                        var value = valueIterator.Current;
                        if (value.HasValue)
                        {
                            elementIterator.Current.Value = value.Value;
                        }
                    }
                }

            return(copy);
        }