public PuzzleSolver(Puzzle puzzle) { this.puzzle = puzzle; lineSolvers = new List <LineSolver>(); foreach (Line line in puzzle.Lines) { var lineSolver = new LineSolver(line); lineSolver.OwnerPuzzle = this; lineSolvers.Add(lineSolver); } cellSolvers = new List <CellSolver>(); foreach (Cell cell in puzzle.Cells) { var cellSolver = new CellSolver(cell); cellSolver.OwnerPuzzle = this; cellSolvers.Add(cellSolver); } foreach (var row in lineSolvers.Where(l => l.line.IsRow)) { foreach (var column in lineSolvers.Where(l => !l.line.IsRow)) { var cell = cellSolvers.Find(c => c.cell.Row == row.line && c.cell.Column == column.line); row.cellSolvers.Add(cell); foreach (var clue in row.clueSolvers) { clue.PossSections.First().Add(cell); } column.cellSolvers.Add(cell); } } }
public PuzzleSolver(Puzzle puzzle) { this.puzzle = puzzle; lineSolvers = new List<LineSolver>(); foreach (Line line in puzzle.Lines) { var lineSolver = new LineSolver(line); lineSolver.OwnerPuzzle = this; lineSolvers.Add(lineSolver); } cellSolvers = new List<CellSolver>(); foreach (Cell cell in puzzle.Cells) { var cellSolver = new CellSolver(cell); cellSolver.OwnerPuzzle = this; cellSolvers.Add(cellSolver); } foreach (var row in lineSolvers.Where(l => l.line.IsRow)) { foreach (var column in lineSolvers.Where(l => !l.line.IsRow)) { var cell = cellSolvers.Find(c => c.cell.Row == row.line && c.cell.Column == column.line); row.cellSolvers.Add(cell); foreach (var clue in row.clueSolvers) { clue.PossSections.First().Add(cell); } column.cellSolvers.Add(cell); } } }