Skip to content

Commit 099ac93

Browse files
committed
Upload project
1 parent 56358a2 commit 099ac93

File tree

9 files changed

+54
-52
lines changed

9 files changed

+54
-52
lines changed

.github/workflows/workflow.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: GitHub Pages Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [ 14.17 ]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v1
20+
21+
- name: Build WASM and page
22+
run: npm install && npm run gh-build
23+
24+
- name: Deploy
25+
uses: JamesIves/[email protected]
26+
with:
27+
branch: gh-pages
28+
folder: build

README.md

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,15 @@
1-
# Getting Started with Create React App
1+
# Sudoku Solver
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
An algorithm made in rust to solve sudoku boards of various sizes efficiently. It's implemented in Rust and runs in the
4+
browser using Web Assembly. The project includes a modern interface made in React to visualise the algorithm
5+
step-by-step.
46

5-
## Available Scripts
7+
## Features
8+
* 3 board options: 4x4 9x9 16x16
9+
* Generation of random Sudoku puzzles
10+
* Algorithm made in Rust to solve puzzles in milliseconds
11+
* Step-by-step visualization of the solution with explanations
612

7-
In the project directory, you can run:
8-
9-
### `npm start`
10-
11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13-
14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `npm test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `npm run build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `npm run eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
13+
## Screenshots
14+
* ![Empty board](https://github.com/cau777/sudoku_solver/blob/master/screenshots/empty_board.png)
15+
* ![Solution step](https://github.com/cau777/sudoku_solver/blob/master/screenshots/solution_step.png)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "sudoku_solver",
33
"version": "0.1.0",
44
"private": true,
5+
"homepage": "https://cau777.github.com/sudoku_solver",
56
"dependencies": {
67
"@testing-library/jest-dom": "^5.16.4",
78
"@testing-library/react": "^13.3.0",
@@ -23,7 +24,8 @@
2324
"test": "react-scripts test",
2425
"eject": "react-scripts eject",
2526
"build:wasm:dev": "cd wasm && wasm-pack build --target web --out-dir pkg --dev",
26-
"build:wasm": "cd wasm && wasm-pack build --target web --out-dir pkg --release -- --features wasm_alloc"
27+
"build:wasm": "cd wasm && wasm-pack build --target web --out-dir pkg --release -- --features wasm_alloc",
28+
"gh-pages": "npm run build:wasm && npm run build"
2729
},
2830
"eslintConfig": {
2931
"extends": [

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>React App</title>
27+
<title>Sudoku Solver</title>
2828
</head>
2929
<body>
3030
<noscript>You need to enable JavaScript to run this app.</noscript>

screenshots/empty_board.png

26.8 KB
Loading

screenshots/solution_step.png

30.6 KB
Loading

src/SudokuController.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ export const SudokuController: React.FC<Props> = (props) => {
120120
readonly={state.steps !== null}></SudokuBoard>
121121
<div className={"buttons"}>
122122
<select defaultValue={3}
123-
onChange={(e) => setState({
124-
...state,
125-
board: Board.default(Number.parseInt(e.currentTarget.value))
126-
})}>
123+
onChange={(e) => setState(defaultState(Board.default(Number.parseInt(e.currentTarget.value))))}>
127124
<option value={2}>4x4</option>
128125
<option value={3}>9x9</option>
129126
<option value={4}>16x16</option>
@@ -149,8 +146,12 @@ export const SudokuController: React.FC<Props> = (props) => {
149146
:
150147
<>
151148
<button onClick={hideSolution}>Hide solution</button>
152-
<button disabled={state.currentStep <= 0} onClick={() => changeCurrentStep(state.currentStep! - 1, state.steps!)}>Prev step</button>
153-
<button disabled={state.currentStep >= state.steps!.length - 1} onClick={() => changeCurrentStep(state.currentStep! + 1, state.steps!)}>Next step</button>
149+
<button disabled={state.currentStep <= 0}
150+
onClick={() => changeCurrentStep(state.currentStep! - 1, state.steps!)}>Prev step
151+
</button>
152+
<button disabled={state.currentStep >= state.steps!.length - 1}
153+
onClick={() => changeCurrentStep(state.currentStep! + 1, state.steps!)}>Next step
154+
</button>
154155
</>
155156
}
156157

wasm/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ harness = false
2626
[profile.release]
2727
lto = true
2828
opt-level = 3
29+
codegen-units = 1
30+
panic = "abort"
2931

3032
[features]
3133
wasm_alloc = ["wee_alloc/default"]

wasm/src/sudoku_solver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<const SIZE: usize, const BLOCK_SIZE: usize> SudokuSolver<SIZE, BLOCK_SIZE>
8787

8888
if self.should_add() {
8989
info_stack.push_front(ReportStep {
90-
message: format!("Tried value {} in {} {}", possible, row, col),
90+
message: format!("Tried value {} in {},{}", possible, row, col),
9191
highlight_row: Some(row as u8),
9292
highlight_col: Some(col as u8),
9393
highlight_block: None,

0 commit comments

Comments
 (0)