Skip to content

Commit

Permalink
feat: change solve functions
Browse files Browse the repository at this point in the history
  • Loading branch information
komeilmehranfar committed Dec 6, 2023
1 parent a47107a commit 249b096
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 280 deletions.
342 changes: 171 additions & 171 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@
"dist"
],
"devDependencies": {
"@commitlint/cli": "^18.2.0",
"@commitlint/config-conventional": "^18.1.0",
"@types/jest": "^29.5.8",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@types/jest": "^29.5.10",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"pinst": "^3.0.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.0",
"typescript": "^5.2.2",
"ts-loader": "^9.5.1",
"typescript": "^5.3.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
Expand Down
23 changes: 13 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSudokuInstance } from "./sudoku";
import { AnalyzeData, Board, Difficulty } from "./types";
import { AnalyzeData, Board, Difficulty, SolvingStep } from "./types";

export { type AnalyzeData, type Board, type Difficulty };
export { type AnalyzeData, type Board, type Difficulty, type SolvingStep };

export function generate(difficulty: Difficulty): Board {
const { getBoard } = createSudokuInstance({ difficulty });
Expand All @@ -13,12 +13,15 @@ export function analyze(Board: Board): AnalyzeData {
return analyzeBoard();
}

export function solve(Board: Board): Board {
const { solveAll } = createSudokuInstance({ initBoard: Board });
return solveAll();
}

export function solveStep(Board: Board): Board {
const { solveStep } = createSudokuInstance({ initBoard: Board });
return solveStep();
export function solve(Board: Board): {
board: Board;
steps: SolvingStep[];
} {
const solvingSteps: SolvingStep[] = [];
const { solveAll } = createSudokuInstance({
initBoard: Board,
onUpdate: (solvingStep) => solvingSteps.push(solvingStep),
});
const board = solveAll();
return { board, steps: solvingSteps };
}
Loading

0 comments on commit 249b096

Please sign in to comment.