/// <summary> <!-- {{{1 --> Convert to the path /// </summary> /// <returns></returns> public Path ToPath() { var ret = new List <Cell>(); foreach (var c in SudokuCellIndexExtension.IndexList()) { var h = SudokuCellIndexExtension.ToHouseIndex(c); var cellsInHouse = CellsFromHouse(h); var cell = this.board.ElementAt((int)c); var updatedCell = cell.ToUpdatedCell(cellsInHouse); ret.Add(updatedCell); } return(new Path(ret)); }
/// <summary> <!-- {{{1 --> Load sudoku cell value from string /// </summary> /// <param name="pat"></param> /// <returns></returns> public bool LoadFromStr(string pat) { if ((SudokuCellIndex.MAX - SudokuCellIndex.MIN + 1) > pat.Length) { return(true); } var vals = SudokuCellIndexExtension.IndexList() .Select(x => SudokuValueExtension.FromStr( pat.Substring((int)x, 1))); var items = this.board.Zip(vals, (c, v) => new { Cell = c, Val = v }); foreach (var i in items) { i.Cell.CopyFrom(i.Val); } return(false); }
/// <summary> <!-- {{{1 --> Convert house index to cell indexes in row. /// </summary> /// <param name="self"></param> /// <returns></returns> public static IEnumerable <SudokuCellIndex> ToCellsIndexInRow(this SudokuHouseIndex self) { return(SudokuCellIndexExtension.IndexList() .Skip(self.ToInt() * 9).Take(9)); }
/// <summary> <!-- {{{1 --> Constructor /// </summary> public Sudoku() { this.board = SudokuCellIndexExtension.IndexList() .Select(x => new Cell(x)).ToArray(); }