Skip to content

Commit

Permalink
finalize alpha 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
potatochick2020 committed Oct 4, 2022
1 parent 8bbbb95 commit f66063c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# Sudoku
A C++ library for generating, validating, solving, checking, etc Sudoku puzzle.

# Installation
'make sudoku.cpp'
'./sudoku'

# Todo

## Code

- [ ] Create Header files

As what it stated ...

- [ ] Reorganize code using OOP approach

This is my first CPP project, I don't think I wrote OOP code properly.

- [ ] Optimised code for performance

The function 'SudokuSolution()' is an enhanced version of [ leetcode - Sudoku solver ]( https://leetcode.com/problems/sudoku-solver/ )

- [ ] Rename variable

I wrote this in a rush , some variable is not named properly and are not consistent. rename it with meaningful variable name

- [ ] Testing

Testing is important. Any testing framework is fine but personally prefer bash scripting to test out the function.

- [ ] Better output format

Print it properly? Probably it will be ideal that I could see obvious changes to show the border of 3x3 box.

## No Code

- [ ] documentation

Provide Documentation on each function on what it does. Please also provide documentation on elaboration on the algorithm especially for 'SudokuSolution()' and 'initialize()'

# How to start contribute

Please discuss in issues and I will assign the issues to you.
Once it is assigned,

1. fork the repo
2. open a draft Pull Request

# Special thanks



Binary file modified sudoku
Binary file not shown.
26 changes: 5 additions & 21 deletions sudoku.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool Sudoku::GenerateSudoku()
std::shuffle(numbers.begin(), numbers.end(), std::mt19937{std::random_device{}()});
for (int number : numbers)
{
if (isPlacable(row, col, Board, number))
if (isPlacable(row, col, number))
{
// if (true){
Board[row][col] = number;
Expand Down Expand Up @@ -177,7 +177,7 @@ int Sudoku::SudokuSolution()
vector<int> numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
for (int number : numbers)
{
if (isPlacable(row, col, Board, number))
if (isPlacable(row, col, number))
{
Board[row][col] = number;

Expand Down Expand Up @@ -227,28 +227,12 @@ int main()
{
Sudoku sudoku;
sudoku.initialize();
vector<vector<int>> temp = vector<vector<int>>(9, vector<int>(9, 0));

// cout<<"empty row 1 | col 1 | value "<<temp[1][1]<<endl;
// temp[1][1] = 0;
// cout<<"empty row 1 | col 2 | value "<<temp[1][2]<<endl;
// temp[1][2] = 0;
// cout<<"empty row 1 | col 3 | value "<<temp[1][3]<<endl;
// temp[1][3] = 0;

// temp[3] = {0,0,0,0,0,0,0,0,0};
// temp[4] = {0,0,0,0,0,0,0,0,0};
// temp[5] = {0,0,0,0,0,0,0,0,0};

int ans = 0;
ans = sudoku.SudokuSolution();
cout<<"ans:"<<ans<<endl;
temp = sudoku.getBoard();
for (auto x : temp)
for (auto row : sudoku.getBoard())
{
for (auto y : x)
for (auto val : row)
{
cout << y << " | ";
cout << val << " | ";
}
cout << endl
<< "--------------------------------" << endl;
Expand Down

0 comments on commit f66063c

Please sign in to comment.