public void Solve(Puzzle puzzle) { _cancellationTokenSource = new CancellationTokenSource(); Task.Factory.StartNew( SolvePuzzleInBackground, puzzle, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
public PuzzleSolver(Puzzle puzzle, CancellationToken cancellationToken) { _puzzle = puzzle; _cancellationToken = cancellationToken; }
public void Solve(Puzzle puzzle) { _onSearchStepCalls.ForEach(x => _onSearchStep(x.Item1, x.Item2)); }
private static IImmutableList<InternalRow> BuildInternalRows(Puzzle puzzle) { var rowsByCols = from row in Rows from col in Cols let coords = new Coords(row, col) let initialValue = puzzle.InitialValues.FirstOrDefault(iv => iv.Coords.Equals(coords)) select BuildInternalRowsForCell(coords, initialValue); return rowsByCols.SelectMany(cols => cols).ToImmutableList(); }