Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kennedymwavu/sudokur
Sudoku puzzle solver
https://github.com/kennedymwavu/sudokur
Last synced: 16 days ago
JSON representation
Sudoku puzzle solver
- Host: GitHub
- URL: https://github.com/kennedymwavu/sudokur
- Owner: kennedymwavu
- License: agpl-3.0
- Created: 2021-04-28T15:59:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-21T18:04:25.000Z (almost 2 years ago)
- Last Synced: 2023-03-10T15:59:06.787Z (over 1 year ago)
- Language: R
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# {sudokur}
This package is designed to solve any 9 by 9 sudoku grid using the backtracking algorithm.
## Installation
You can install the development version of sudokur from [GitHub](https://github.com/) with:
```{r include=FALSE}
devtools::load_all('.')
`````` r
# install.packages("devtools")
devtools::install_github("kennedymwavu/sudokur")
```## Usage
### Include your own sudoku grids
To make your own customized sudoku puzzle which you can view and solve with the functions available in this package, create a 9 by 9 matrix with zeros representing the empty spaces in your sudoku.
Example:
```{r}
board1 <- matrix(
data = c(
5, 6, 0, 8, 4, 7, 0, 0, 0,
3, 0, 9, 0, 0, 0, 6, 0, 0,
0, 0, 8, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 8, 0, 0, 4, 0,
7, 9, 0, 6, 0, 2, 0, 1, 8,
0, 5, 0, 0, 3, 0, 0, 9, 0,
0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 0, 6, 0, 0, 0, 8, 0, 7,
0, 0, 0, 3, 1, 6, 0, 5, 9
),
ncol = 9
)
```### Pretty print a sudoku grid
To pretty print a sudoku grid use `print_board(given_board)`.
Example:
```{r}
print_board(board1)
```### Solve sudoku puzzles
To solve a sudoku puzzle `solve_sudoku(given_board)`.
Example:
```{r}
solve_sudoku(samples$board6)
```