{"id":16966563,"url":"https://github.com/erelado/py-sudoku","last_synced_at":"2025-03-21T17:37:57.498Z","repository":{"id":130985566,"uuid":"383631244","full_name":"erelado/py-sudoku","owner":"erelado","description":"A simple Python program that generates and solves Sudoku board (9x9) puzzles.","archived":false,"fork":false,"pushed_at":"2021-07-07T00:58:14.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T12:41:28.245Z","etag":null,"topics":["console-application","python-console","python3","sudoku","sudoku-generator","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/erelado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-07T00:32:58.000Z","updated_at":"2023-02-05T13:05:28.000Z","dependencies_parsed_at":"2023-04-22T12:22:45.451Z","dependency_job_id":null,"html_url":"https://github.com/erelado/py-sudoku","commit_stats":null,"previous_names":["erelado/py-sudoku"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-sudoku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-sudoku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-sudoku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-sudoku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erelado","download_url":"https://codeload.github.com/erelado/py-sudoku/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244841540,"owners_count":20519421,"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":["console-application","python-console","python3","sudoku","sudoku-generator","sudoku-solver"],"created_at":"2024-10-14T00:06:15.207Z","updated_at":"2025-03-21T17:37:57.473Z","avatar_url":"https://github.com/erelado.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py-sudoku (console)\n\n## 📙 Description\nA simple Python program that generates and solves Sudoku board (9x9) puzzles.\n\n### 📏 Scope\nThe goal of the project was to examine Python's basic syntax and provide added educational value.\n\nThe first part of the project was to create a sudoku board solver.\nA sudoku board generator was later added to the project.\n\n### 🔗 References\nInspiration taken from:\n- [jeffsieu / py-sudoku](https://github.com/jeffsieu/py-sudoku).\n- [techwithtim](https://www.youtube.com/watch?v=eqUwSA0xI-s\u0026list=PLzMcBGfZo4-kE3aF6Y0wNBNih7hWRAU2o) / [Sudoku-GUI-Solver](https://github.com/techwithtim/Sudoku-GUI-Solver).\n\n\\\n\u0026nbsp;\n\n# 🚩 Usage\n\n### Generating a Sudoku board\n```py\nfrom Sudoku import SudokuBoardGenerator, SudokuBoardSolver, print_board\n\npuzzle = SudokuBoardGenerator()    # Generator initializion.\npuzzle.generate_unsolved_board(5)  # Sudoku board generation (difficulty = 5 attempts).\nprint_board(puzzle.board)          # Printing the result.\n\n# Generating a new Sudoku board to solve...\n# generated a new board in 1.1324846744537354 seconds\n\n# 0 0 3 | 0 5 4 | 2 0 9\n# 0 9 1 | 3 0 2 | 4 8 0\n# 0 8 4 | 0 9 0 | 0 0 0\n# ------|-------|------\n# 8 0 6 | 0 0 0 | 0 0 0\n# 4 3 0 | 0 0 7 | 0 0 0\n# 0 5 9 | 0 2 6 | 0 0 0\n# ------|-------|------\n# 6 0 5 | 0 0 0 | 3 0 1\n# 0 0 0 | 0 1 5 | 0 0 8\n# 0 0 0 | 0 0 0 | 0 7 0\n```\n\n### Solving a Sudoku board\nSolving a board that has been pre-generated by the algorithm.\n```py\nfrom Sudoku import SudokuBoardGenerator, SudokuBoardSolver, print_board\n\n# using the generated \"puzzle\"\npuzzle = SudokuBoardGenerator()          # Generator initializion.\npuzzle.generate_unsolved_board(5)        # Sudoku board generation (difficulty = 5 attempts).\n\nsolver = SudokuBoardSolver(puzzle.board) # Solver initializion.\nsolver.solve_board()                     # Sudoku board solution.\nprint_board(solver.board)                # Printing the result.\n\n# Generating a new Sudoku board to solve...\n# generated a new board in 1.1324846744537354 seconds\n\n# solved in 0.03597092628479004 seconds\n\n# 7 6 3 | 8 5 4 | 2 1 9\n# 5 9 1 | 3 7 2 | 4 8 6\n# 2 8 4 | 6 9 1 | 7 5 3\n# ------|-------|------\n# 8 7 6 | 5 3 9 | 1 4 2\n# 4 3 2 | 1 8 7 | 9 6 5\n# 1 5 9 | 4 2 6 | 8 3 7\n# ------|-------|------\n# 6 2 5 | 7 4 8 | 3 9 1\n# 3 4 7 | 9 1 5 | 6 2 8\n# 9 1 8 | 2 6 3 | 5 7 4\n```\n\n### Importing boards\nYou can also import Sudoku boards from an outsourcer.\n```py\nfrom Sudoku import SudokuBoardGenerator, SudokuBoardSolver, print_board\n\n# using \"World's hardest sudoku: can you crack it?\"\n# @ https://www.telegraph.co.uk/news/science/science-news/9359579/Worlds-hardest-sudoku-can-you-crack-it.html\nhardest_sudoku = [\n    [8,0,0,0,0,0,0,0,0],\n    [0,0,3,6,0,0,0,0,0],\n    [0,7,0,0,9,0,2,0,0],\n    [0,5,0,0,0,7,0,0,0],\n    [0,0,0,0,4,5,7,0,0],\n    [0,0,0,1,0,0,0,3,0],\n    [0,0,1,0,0,0,0,6,8],\n    [0,0,8,5,0,0,0,1,0],\n    [0,9,0,0,0,0,4,0,0]\n    ]\n\nsolver = SudokuBoardSolver(hardest_sudoku) # Solver initializion.\nsolver.solve_board()                       # Sudoku board solution.\nprint_board(solver.board)                  # Printing the result.\n\n# solved in 1.8471145629882812 seconds\n\n# 8 1 2 | 7 5 3 | 6 4 9\n# 9 4 3 | 6 8 2 | 1 7 5\n# 6 7 5 | 4 9 1 | 2 8 3\n# ------|-------|------\n# 1 5 4 | 2 3 7 | 8 9 6\n# 3 6 9 | 8 4 5 | 7 2 1\n# 2 8 7 | 1 6 9 | 5 3 4\n# ------|-------|------\n# 5 2 1 | 9 7 4 | 3 6 8\n# 4 3 8 | 5 2 6 | 9 1 7\n# 7 9 6 | 3 1 8 | 4 5 2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferelado%2Fpy-sudoku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferelado%2Fpy-sudoku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferelado%2Fpy-sudoku/lists"}