{"id":17259467,"url":"https://github.com/muneeb706/sudoku-solver","last_synced_at":"2025-10-13T20:39:30.837Z","repository":{"id":154490571,"uuid":"248147334","full_name":"muneeb706/sudoku-solver","owner":"muneeb706","description":"A program which will read a sudoku puzzle from a file (some examples are sudoku1.txt, sudoku2.txt, etc) and generate clauses in the DIMACS format for each sudoku puzzle in the files sudokuN.cnf, where N = 1, 2, ..., 5.","archived":false,"fork":false,"pushed_at":"2020-03-25T22:24:34.000Z","size":2127,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T20:39:30.427Z","etag":null,"topics":["cnf","dimacs","latin-square","logic-in-computer-science","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muneeb706.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-18T05:36:01.000Z","updated_at":"2021-11-09T09:57:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c04d60f-7fce-47b0-9925-3946307a4f64","html_url":"https://github.com/muneeb706/sudoku-solver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/muneeb706/sudoku-solver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muneeb706%2Fsudoku-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muneeb706%2Fsudoku-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muneeb706%2Fsudoku-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muneeb706%2Fsudoku-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muneeb706","download_url":"https://codeload.github.com/muneeb706/sudoku-solver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muneeb706%2Fsudoku-solver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016929,"owners_count":26085910,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cnf","dimacs","latin-square","logic-in-computer-science","python"],"created_at":"2024-10-15T07:45:07.319Z","updated_at":"2025-10-13T20:39:30.820Z","avatar_url":"https://github.com/muneeb706.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sudoku Puzzle Solver\n\nThis project contains two types of sudoku puzzle solver. Following is the description for both types of sudoku solvers:\n\n## 1. Basic Sudoku Solver\n\nA python program which will read a sudoku puzzle from a file (some examples are sudoku1.txt, sudoku2.txt, etc) and generate clauses in the DIMACS format for each sudoku puzzle in the files sudokuN.cnf, where N = 1, 2, ..., 5.\n\nPlase refer to the article (http://sat.inesc.pt/~ines/publications/aimath06.pdf) to understand the problem.\n\nPython Program uses the propositional variables S(i,j,d) for a Sudoku puzzle, which is true iff the digit in the cell at row i and column j is d, where i, j, and d are in { 1, 2, ..., 9 }. To encode this variable into an integer in the DIMACS format, we have used following formula:\n\n           code(i, j, d) = 100*i+10*j+d\n           \nAs a result, the maximal variable index is 999, instead of 729. So the first line output by the program is\n\np cnf 999 999999\n\nSolution of a puzzle can be figured out by looking at the output of minisat.\n\nAn executable of minisat for linux can be downloaded from here: (http://minisat.se/). You might need to run\n\n    chmod a+x minisat.exe\n    \non linux before running minisat.exe. You need to run minisat as\n    \n    cat sudoku1.cnf | ./minisat.exe stdin sudoku1.out\n\n## 2. Latin Square Sudoku Solver\n\nA Latin square over N = {0, 1, ..., n-1} is an n by n square where each row and each column of the square is a permutation of the numbers from N. Here n is said to be the order of the square. Note that a Sudoku puzzle is a special Latin square over M = {1, 2, ..., 9} with the additional condition that each of the nine 3x3 regions is also a permutation of M.\n\nPython program uses the propositional variables S(i,j,d) for a Latin square, which is true iff the number in the cell at row i and column j is d in the square, where i, j, and d are in N. To encode this variable into an integer in the DIMACS format, please use\n\n           code(i, j, d) = 100*i+10*j+d+1\n           \nPython program specifies the Latin square in propositional logic for n = 4, 5, 6, 7, 8, and 9, with the following two additional conditions: For all x, y, z, w in N:\n- S(x,x,x)\n- -S(x,y,z) \\/ -S(y,x,w) \\/ S(z,w,x)\n\nwhere \"-\" is for negation, such that the set of clauses is satisfiable iff the Latin square with the above two conditions over N = {0, 1, ..., n-1} exists.\nPython program reads an integer n and generates propositional clauses in DIMACS format for the Latin square of order N. Program saves these clauses in a file called lsquareN.cnf, where N is a number, then run minisat on lsquareN.cnf as mentioned in the description of basic sudoku solver above.\n\n- #### Note: \n           If we regard the Latin square as the definition for the operation *, such that x*y = z iff S(x,y,z) is true, then the first formula above says x*x = x, and the second formula says (x*y)*(y*x) = x.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuneeb706%2Fsudoku-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuneeb706%2Fsudoku-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuneeb706%2Fsudoku-solver/lists"}