{"id":17279687,"url":"https://github.com/ortham/sudoku-solver","last_synced_at":"2025-03-26T14:46:10.189Z","repository":{"id":148930881,"uuid":"396008507","full_name":"Ortham/sudoku-solver","owner":"Ortham","description":"A CLI sudoku solver.","archived":false,"fork":false,"pushed_at":"2022-01-08T21:08:44.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T16:15:44.477Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Ortham.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,"publiccode":null,"codemeta":null}},"created_at":"2021-08-14T12:53:31.000Z","updated_at":"2021-08-23T13:41:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"03703c85-1d2e-417e-9e53-6af121f7eb76","html_url":"https://github.com/Ortham/sudoku-solver","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/Ortham%2Fsudoku-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fsudoku-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fsudoku-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fsudoku-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ortham","download_url":"https://codeload.github.com/Ortham/sudoku-solver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245675623,"owners_count":20654432,"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":[],"created_at":"2024-10-15T09:18:17.425Z","updated_at":"2025-03-26T14:46:10.163Z","avatar_url":"https://github.com/Ortham.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sudoku Solver\n=============\n\nThis is a clean room implementation (meaning I have no idea what I'm doing) of a\nsudoku solver. The application reads a sudoku grid from stdin and prints the\nsolved grid to stdout.\n\nThe input grid must be laid out as nine lines of nine whitespace-separated\nsymbols: anything that is not a non-zero number or whitespace will be\ninterpreted as an empty cell in the grid that needs solving. Once nine lines\nhave been read, the solver stops reading input and starts calculating the\nsolution.\n\nThe solver logic is not complicated or particularly clever: it just loops over\neach cell in the grid and checks what the possible values are given other values\npresent in the same row, column and 3x3 box. For each possible value, it creates\na copy of the grid with that value substituted in, and then attempts to solve\nthat grid. If a grid turns out to be unsolvable (i.e. it finds that a cell has\nno possible values), it discards that grid. Assuming the sudoku puzzle is\nactually solveable, it ends up with a grid with all cells filled, and stops\nthere.\n\nI've attempted to avoid allocating on the heap inside the solver's hot loop,\nwhich is why there are a lot of fixed-size arrays used. This does seem to have\nan impact on performance, though my measurements were very unrigorous and the\nsolver was already fast enough for my needs anyway.\n\nTo build:\n\n```\ncargo build --release\n```\n\nHere's some example input and output, using underscores to indicate empty cells:\n\n```powershell\nPS C:\\sudoku-solver\u003e echo \"4 _ _ _ _ _ _ _ _\n\u003e\u003e _ _ _ 2 1 8 _ 7 _\n\u003e\u003e 7 _ _ _ 9 _ _ _ 2\n\u003e\u003e _ _ 6 _ 3 _ 8 _ 4\n\u003e\u003e 1 _ _ _ _ _ _ 2 _\n\u003e\u003e _ _ 5 _ _ 7 _ _ _\n\u003e\u003e _ 1 _ _ 6 _ _ _ _\n\u003e\u003e _ 6 _ _ 8 5 _ _ _\n\u003e\u003e _ _ 9 _ _ _ _ _ 1\" | .\\target\\release\\sudoku-solver.exe\nSolved sudoku in 22158 loops!\nTook 2 ms to solve\nSolved values:\n4 8 2 7 5 3 9 1 6\n6 9 3 2 1 8 4 7 5\n7 5 1 4 9 6 3 8 2\n2 7 6 5 3 1 8 9 4\n1 3 8 6 4 9 5 2 7\n9 4 5 8 2 7 1 6 3\n5 1 4 9 6 2 7 3 8\n3 6 7 1 8 5 2 4 9\n8 2 9 3 7 4 6 5 1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortham%2Fsudoku-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fortham%2Fsudoku-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortham%2Fsudoku-solver/lists"}