コード例 #1
0
        public MutablePuzzle AsMutable()
        {
            var newCells = new IndexablePosition[_cells.Length];

            Array.Copy(_cells, newCells, _cells.Length);

            return(new MutablePuzzle(newCells));
        }
コード例 #2
0
        public static Puzzle FromString(string puzzle)
        {
            var positions = new IndexablePosition[LineLength * LineLength];

            for (var i = 0; i < positions.Length; i++)
            {
                var value = SudokuValues.FromCharacter(puzzle[i]);
                var coord = new Coordinate(RegionType.Row, i);

                positions[coord.GlobalRowIndex]    = positions[coord.GlobalRowIndex].SetRowValue(value);
                positions[coord.GlobalColumnIndex] = positions[coord.GlobalColumnIndex].SetColumnValue(value);
                positions[coord.GlobalBoxIndex]    = positions[coord.GlobalBoxIndex].SetBoxValue(value);
            }

            return(new Puzzle(positions));
        }