Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonas-is-coding/sudoku-bruteforce

A Sudoku solver via brute forcing in C++
https://github.com/jonas-is-coding/sudoku-bruteforce

brute-force cpp solver sudoku

Last synced: 25 days ago
JSON representation

A Sudoku solver via brute forcing in C++

Awesome Lists containing this project

README

        

# Sudoku Brute Forcer

This project implements a Sudoku solver via brute forcing in C++. The solver can solve any given Sudoku puzzle, with varying difficulty levels.

## Inspiration

This project was inspired by a [YouTube Shorts video](https://www.youtube.com/watch?app=desktop&v=4c_16yiQBfI). Later, I wrote a [blog article](https://www.jonasbrahmst.me/blog/create-a-sudoku-bruteforcing-script-in-cpp) explaining how I implemented the solver and the steps I took to build it. Feel free to check out both resources for a more detailed explanation!

## Requirements

- C++11 or later
- A C++ compiler (e.g., `g++`)

## Installation

1. Clone this repository:
```bash
git clone https://github.com/jonas-is-coding/sudoku-solver.git
```
2. Navigate to the project directory:
```bash
cd sudoku-solver
```
3. Compile the project using g++:
```bash
g++ -std=c++11 -O2 main.cpp -o sudoku-solver
```
4. Run the executable:
```bash
./sudoku-solver
```

## Usage

1. Generating a Sudoku Puzzle: The program generates a new Sudoku puzzle based on the specified fill percentage, where a higher percentage means an easier puzzle.
2. Solving a Sudoku Puzzle: If a Sudoku puzzle is provided as input, the program will solve it using a backtracking algorithm.

## File Structure

- main.cpp: Main entry point of the application.
- solve.hpp and solve.cpp: Contains the logic for solving the Sudoku puzzle.
- generate.hpp and generate.cpp: Contains the logic for generating Sudoku puzzles.
- check.hpp: Contains the validation functions for checking whether a Sudoku puzzle is valid.
- types.hpp: Defines the board structure (board_t), a 9x9 matrix representing the Sudoku grid.