コード例 #1
0
 // ReSharper disable once UnusedMember.Global
 /// <summary>
 /// Copy Constructor.
 /// </summary>
 /// <param name="other"></param>
 public SudokuPuzzle(SudokuPuzzle other)
 {
     _grid = new Dictionary <Address, int>();
     foreach (var item in other._grid)
     {
         _grid.Add(new Address(item.Key), item.Value);
     }
 }
コード例 #2
0
        /// <summary>
        /// Returns a Sudoku SudokuPuzzle based on the <paramref name="values"/>. Values are
        /// treated in row major manner. Each value is validated first and foremost.
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public static SudokuPuzzle ToSudokuPuzzle(this int[] values)
        {
            foreach (var value in values)
            {
                value.VerifyValue();
            }

            var result = new SudokuPuzzle();

            for (var row = MinimumValue; row < MaximumValue; row++)
            {
                for (var column = MinimumValue; column < MaximumValue; column++)
                {
                    result[new Address(row, column)] = values[row * MaximumValue + column];
                }
            }

            return(result);
        }