{"id":20304357,"url":"https://github.com/dev-michael-schmidt/sudoku-solver","last_synced_at":"2025-04-11T14:14:54.463Z","repository":{"id":106652911,"uuid":"163791504","full_name":"dev-michael-schmidt/sudoku-solver","owner":"dev-michael-schmidt","description":"A simple Python program which solves Sudoku using reasoning and greedy depth first search.","archived":false,"fork":false,"pushed_at":"2021-08-16T14:40:13.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T10:22:11.619Z","etag":null,"topics":["depth-first-search","jupyter-notebook","python3","sudoku-solver"],"latest_commit_sha":null,"homepage":"","language":"Python","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/dev-michael-schmidt.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-02T03:49:36.000Z","updated_at":"2024-03-26T20:17:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"844372bd-0aa4-4a47-8dac-75e57dfa5c30","html_url":"https://github.com/dev-michael-schmidt/sudoku-solver","commit_stats":null,"previous_names":["dev-michael-schmidt/sudoku-solver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-michael-schmidt%2Fsudoku-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-michael-schmidt%2Fsudoku-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-michael-schmidt%2Fsudoku-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-michael-schmidt%2Fsudoku-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-michael-schmidt","download_url":"https://codeload.github.com/dev-michael-schmidt/sudoku-solver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248415602,"owners_count":21099707,"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":["depth-first-search","jupyter-notebook","python3","sudoku-solver"],"created_at":"2024-11-14T16:43:56.870Z","updated_at":"2025-04-11T14:14:54.440Z","avatar_url":"https://github.com/dev-michael-schmidt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sudoku-solver\nA python program to solve sudoku puzzles.\n\n### Files\n- `*.sudoku`: a game file.  \n- `annotated_board.py`: contains an `AnnotatedBoard` class which holds and operates on the sudoku puzzle.\n- `checker.py`: a simple script to check if a puzzle contains a valid solution.  No longer maintained (use `AnnotatedBoard.is_valid()`).\n- `sudoku.ipynb`: Jupyter Notebook with DFS search algorithm for puzzles where a solution can't be solved solely via deduction.\n\n### Functions\n`AnnotatedBoard`\n- `self.__init__(self, board=None)`:  Initialize a blank puzzle or use an `AnnotatedBoard` to make a copy.\n\n- `self.__repr__(self)`: for interactive interpreters. displays in Type(known, completed, validity) format.\n\n- `self.__str__(self)`: convert the board to a print pretty format for use with `print()` function. i.e:\n```\ngame = AnnotatedBoard()\ngame.from_file('hard1.sudoku')\ngame = DFS(game)\nprint(game)\n5 1 9 | 7 4 8 | 6 3 2\n7 8 3 | 6 5 2 | 4 1 9\n4 2 6 | 1 3 9 | 8 7 5\n------+-------+------\n3 5 7 | 9 8 6 | 2 4 1\n2 6 4 | 3 1 7 | 5 9 8\n1 9 8 | 5 2 4 | 3 6 7\n------+-------+------\n9 7 5 | 8 6 3 | 1 2 4\n8 3 2 | 4 9 1 | 7 5 6\n6 4 1 | 2 7 5 | 9 8 3\n```\n- `self.__deepcopy__(self, memo)`:  This function may need some work, but provides a mechanism for `copy.deepcopy()` method from the standard library.\n\n- `self.from_file()`: load a puzzle from a file using the specified format.\n\n- `self.from_list_of_lists()`: load a puzzle from a list of lists where elements are string types (WIP).\n\n- `self.element(row, col)`: Return the value, or set({}) of possible values at the specified row and column.\n\n- `self.guess(row, col, value)`: Set a cell value without deduction.  Value must be a possible value for that cell. (Use `element()` for a set of values)\n    - `value == -1`: reset the cell to a set of possibilities.  If cell was a value, updates internal unknown count otherwise recalculates possibilities for cell.\n    - `value == {1 - 9}`: fill the cell with a value.\n        - if value is accepted, returns `True` and updates internal unknown count.\n- `self.unknown_count(self)`: return a count of cells without values.  Updates internal counter.\n\n- `self.full_deduce()`: performs one iteration and deduces values (not sets of values (yet)) on a cell.  One iteration deducts value by scanning possible values in unknown cells, then if a cell contains a unique possibility, that value is placed.  This function works on the ROW, COLUMN, and BLOCK level by calling `self.row_deduce(self)`, `self.col_deduce(self)`, and `self.block_deduce(self)`.  Future work may try to deduce a set of possibilities.  For example, a row/column/block containing:\n    - `{1, 2, 7, 8}`, `{1, 2}`\n    - `{1, 2, 7, 8}`, `{1, 2}`\n\n    should deduce down into:\n    - `{7 ,8}`, `{1, 2}`,\n    - `{7, 8}`, `{1, 2}`\n\n    - returns `True` if the puzzle is valid, otherwise `False`.\n- `self.row_duplicate(self, row=None)`: Scans the puzzle for duplicate values occurring in a row.  If `row` is supplied, only the row is checked.  Returns `True` if a duplicate is found, otherwise `False`.\n\n- `self.col_duplicate(self, col=None)`: Scans the puzzle for duplicate values occurring in a column.  If `col` is supplied, only the column is checked.  Returns `True` if a duplicate is found, otherwise `False`.\n\n- `self.col_duplicate(self, row=None, col=None)`: Scans the puzzle for duplicate values occurring in a block.  If `row` and `col` are supplied, only the corresponding block is checked.  Returns `True` if a duplicate is found, otherwise `False`.\n\n- `self.row_deduce(self)`: to be documented\n- `self.col_deduce(self)`: to be documented\n- `self.block_deduce(self)`: : to be documented\n- `self.is_valid(self, row=None, col=None)`: to be documented\n- `self.row_elimination(self, row=None)`: to be documented\n- `self.col_elimination(self, col=None)`: to be documented\n- - `self.block_elimination(self, row=None, col=None)`: to be documented\n\n\n\n\n\n#### Format\nUse dots to specify unknown cells in a plain text format. include a space between each value.\n```\n2 . . . . . . 6 3\n. . 6 5 8 3 . . 9\n. . 4 1 . . . . 7\n. 6 . . . 1 . 9 8\n. 9 3 . 5 . 6 2 .\n8 2 . 3 . . . 7 .\n6 . . . . 9 7 . .\n5 . . 6 7 8 4 . .\n3 4 . . . . . . 6\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-michael-schmidt%2Fsudoku-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-michael-schmidt%2Fsudoku-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-michael-schmidt%2Fsudoku-solver/lists"}