{"id":21300267,"url":"https://github.com/vaithak/sudoku-generator","last_synced_at":"2025-07-11T19:31:12.557Z","repository":{"id":49363429,"uuid":"138402482","full_name":"vaithak/Sudoku-Generator","owner":"vaithak","description":"A simple sudoku puzzle generator written in C++.","archived":false,"fork":false,"pushed_at":"2023-07-11T10:44:27.000Z","size":193,"stargazers_count":81,"open_issues_count":1,"forks_count":29,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-15T16:27:40.146Z","etag":null,"topics":["algorithm","backtracking-algorithm","cpp","hacktoberfest","hacktoberfest2021","puzzle","puzzle-generator","sudoku","sudoku-game","sudoku-generator","sudoku-puzzle"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vaithak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-23T13:16:41.000Z","updated_at":"2024-03-21T14:42:32.000Z","dependencies_parsed_at":"2022-08-30T05:52:10.497Z","dependency_job_id":null,"html_url":"https://github.com/vaithak/Sudoku-Generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaithak%2FSudoku-Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaithak%2FSudoku-Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaithak%2FSudoku-Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaithak%2FSudoku-Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaithak","download_url":"https://codeload.github.com/vaithak/Sudoku-Generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225750108,"owners_count":17518315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","backtracking-algorithm","cpp","hacktoberfest","hacktoberfest2021","puzzle","puzzle-generator","sudoku","sudoku-game","sudoku-generator","sudoku-puzzle"],"created_at":"2024-11-21T15:09:04.834Z","updated_at":"2024-11-21T15:09:05.428Z","avatar_url":"https://github.com/vaithak.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sudoku-Generator\n  \nA Sudoku puzzle generator written in C++.\n\n## Steps to Use:-  \n\n### Requirements: \n-\u003e git  \n-\u003e Latest version C++ compiler , (this program has been tested on g++ only)   \n\n### Linux and MacOS\n\nType the follwing commands on your terminal (without the '$')  \n```\n$ git clone https://github.com/vaithak/Sudoku-Generator\n$ cd Sudoku-Generator\n$ bash setup.sh\n```  \n\n**Now restart the terminal and you are good to go**  \n\nTo run =\u003e enter `$ sudokuGen` from anywhere in the terminal  \nYou can view the svg image generated in any Browser.  \n\n### Example Puzzle generated from the program\n![image](https://github.com/vaithak/Sudoku-Generator/blob/master/images/example_puzzle.svg)  \n   \n### FlowChart\n\n![image](https://github.com/vaithak/Sudoku-Generator/blob/master/images/flowchart1.png)  \n![image](https://github.com/vaithak/Sudoku-Generator/blob/master/images/flowchart2.png)  \n\n### Working of Step 1 and Step 6:  \n\n**Step 1**  \n```\n =\u003e Empty grid is solved using the normal backtracking method only, \n    but to make the seed different every time, we will not check numbers \n    1-9 sequentially at empty position.\n    \n =\u003e Rather we will shuffle the list containing numbers 1-9 and fill cell according\n    to it.\n    \n =\u003e This ensures every time the program is run, the seed is different.\n```  \n\n**Step 6: Difficulty estimation** \n```\n  \n  Estimating the difficulty of a Sudoku puzzle is a tricky problem because of the\n  variety of techniques human solvers use. \n  \n  A quick and easy method that correlates roughly with difficulty is to keep track of the\n  branch factor at each step on the path from the root of the search tree to the solution.\n\n  We compute a branch-difficulty score by summing (B(i) - 1)^2 at each node, \n  where Bi are the branch factors. \n  \n  A solution which requires no backtracking at all would thus have a branch-difficulty score of 0.\n\n  The final score is given by:  S = B * 100 + E\n  \n  Where B is the branch-difficulty score and E is the number of empty cells. \n  E is included to bias the puzzle generator in the direction of fewer clues, \n  given multiple puzzles with the same branch-difficulty.\n\n  A puzzle which requires no backtracking ends up with a final score of less than 100. \n  \n  However, this naive approach does not correlate well with actual difficulty unless \n  a modification is made to the solver algorithm.\n```   \n\n\n### Modified Solver\n```\n  Rather than considering the possible values for a given empty cell, we could consider\n  possible positions for a given missing value in one of the rows, columns or boxes.\n\n  We make the following modification to the solver:\n\n    1) Choose the cell with the fewest possible candidates. If no such cell can be found, the puzzle is solved.\n\n    2) Search sets (rows, columns and boxes) for missing values, and count the positions they could occupy.\n       Identify the set and value with the fewest number of possible positions.\n\n    3) If the set-search result gives a number of positions which is smaller than the number of candidate values\n       found in step 1, then continue with step 4. Otherwise, continue with step 5.\n\n    4) Try filling the identified value in each candidate position in the set and recursively solve. \n       If all candidate positions are exhausted, signal failure to the caller.\n\n    5) For each candidate value in the cell identified in step 1, place the value in the cell and \n       try to recursively solve the puzzle. If all candidate values are exhausted, signal failure.\n\n  Essentially, the algorithm is the same, except that we try the set-oriented approach \n  if it results in a smaller branch factor. \n  This means that hidden singles or tuples yield similar branch factors to their naked equivalents.\n\n  Making this modification often changes the results of difficulty estimations drastically. \n```  \n\n[Reference](https://utiny.herokuapp.com/gt)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaithak%2Fsudoku-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaithak%2Fsudoku-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaithak%2Fsudoku-generator/lists"}