https://github.com/nathanbuchar/elixir-sudoku
An exploration into complex logic, backtracing, and recursion using Elixir.
https://github.com/nathanbuchar/elixir-sudoku
backtracking elixir recursion sudoku
Last synced: over 1 year ago
JSON representation
An exploration into complex logic, backtracing, and recursion using Elixir.
- Host: GitHub
- URL: https://github.com/nathanbuchar/elixir-sudoku
- Owner: nathanbuchar
- Created: 2017-02-15T07:52:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-22T17:54:07.000Z (over 9 years ago)
- Last Synced: 2025-01-22T07:43:31.034Z (over 1 year ago)
- Topics: backtracking, elixir, recursion, sudoku
- Language: Elixir
- Homepage:
- Size: 83 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elixir Sudoku
An exploration into complex logic, backtracing, and recursion using Elixir. Check out the [Documentation](http://nathanbuchar.github.io/elixir-sudoku).
***
## Usage
```elixir
iex> Sudoku.solve("0,0,0,0,9,7,0,0,6,...,9,0,0,6,4,0,0,0,0")
"1,8,4,3,9,7,2,5,6,...,9,3,1,6,4,2,7,8,5"
```
## Solving Methodology
1. Start
2. Is board valid?
- **Yes** Continue to next step
- **No** Is the solving history empty?
- **Yes** The board is invalid
- **No** Go to step 6
3. Get coordinates of the next empty cell on the board. Does one exist?
- **Yes** Continue to next step
- **No** Congratulations! You have solved the puzzle! :tada:
4. Get all legal values for this cell. Do any exist?
- **Yes** Continue to next step
- **No** Go to step 6
5. Get the next legal value for the current cell. Does one exist?
- **Yes** Set the value of the cell to this value and go to step 1
- **No** Go to step 3
6. Clear the value of this cell and remove it from the history. Go to step 5.
## TODO
* Make concurrent
***
Copyright (c) 2017 [Nathan Buchar](mailto:hello@nathanbuchar.com). All Rights Reserved.