{"id":31548621,"url":"https://github.com/osoleve/sudoku-graph-coloring-julia","last_synced_at":"2026-02-13T20:54:03.342Z","repository":{"id":138842917,"uuid":"333305874","full_name":"osoleve/Sudoku-Graph-Coloring-Julia","owner":"osoleve","description":"A graph-based Sudoku generator and solver, written in Julia","archived":false,"fork":false,"pushed_at":"2021-03-22T00:24:49.000Z","size":199,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T16:39:24.579Z","etag":null,"topics":["graph-coloring","sudoku","sudoku-generator","sudoku-solver"],"latest_commit_sha":null,"homepage":"","language":"Julia","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/osoleve.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-27T04:45:03.000Z","updated_at":"2021-03-22T00:24:51.000Z","dependencies_parsed_at":"2023-03-17T23:15:47.299Z","dependency_job_id":null,"html_url":"https://github.com/osoleve/Sudoku-Graph-Coloring-Julia","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/osoleve/Sudoku-Graph-Coloring-Julia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoleve%2FSudoku-Graph-Coloring-Julia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoleve%2FSudoku-Graph-Coloring-Julia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoleve%2FSudoku-Graph-Coloring-Julia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoleve%2FSudoku-Graph-Coloring-Julia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osoleve","download_url":"https://codeload.github.com/osoleve/Sudoku-Graph-Coloring-Julia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoleve%2FSudoku-Graph-Coloring-Julia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29417705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["graph-coloring","sudoku","sudoku-generator","sudoku-solver"],"created_at":"2025-10-04T16:37:26.974Z","updated_at":"2026-02-13T20:54:03.336Z","avatar_url":"https://github.com/osoleve.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sudoku Generator/Solver\n\nUses a homebrew graph to solve sudokus.\n\n`random_puzzle(s, n)` (where `s` is the Sudoku size and `n` is the number of\nsquares to fill in) is guaranteed to generate a valid puzzle, but not guaranteed to\ngenerate a puzzle with a unique solution.\n\nUse `new_puzzle()` with the same arguments as `random_puzzle` to print directly.\n\n`solve!(graph::SudokuGraph)` ...well, solves the given graph. Currently not\nvery fast for larger puzzles.\n\nFor examples on how to format a puzzle for loading, check out `src/data` and\n`src/puzzle/io.jl`\n\n2 and 3-sudokus have an extra, simplified input method using a string:\n\n```julia\n\u003e g = load_puzzle_string(2, \"4000104334100134\");\n\u003e print(g)\n\n4 1 | 3\n    | 4 1\n-----------\n  4 | 1 3\n  3 |   4\n```\n## Generating a puzzle\n\n```julia\n\u003e g = random_puzzle(3, 33)\n\u003e print(g)\n\n      |   7   |     2\n6   5 | 2 9   | 8   7\n7   2 | 8     |\n---------------------\n3     | 4 5 9 |     1\n1   7 |     2 | 4 9\n2   4 |     7 | 3 8\n---------------------\n      |   1   |\n8     |     6 | 7 5\n      |     4 | 1\n\n\u003e @time g = random_puzzle(4);\n\n0.074973 seconds (646.10 k allocations: 123.388 MiB)\n\n\u003e print(g)\n\n   10  4    |     3  8    |  9 15  6    | 16 12 13  5\n15 14  6  9 | 13  5 12 16 |  4 10 11  2 |  8  3  7  1\n 3  1  8  7 | 15  6  9 14 |       12 13 |     4 10 11\n   13 12 16 | 10          |  8          |     6 14 15\n-----------------------------------------------------\n    2 11  4 |  7     3    |  6 14 15  9 | 12  5 16\n14  9 15    |    13  5 12 | 11  2 10    |  3  1  8  7\n13 16  5    |  2 10 11    |  3  7  1  8 |    15  9 14\n    7  3    |    15     9 |        5    |  4       10\n-----------------------------------------------------\n 8  3     1 |  6  9 14    | 13 12       | 10  2 11  4\n 4 11       |  3  8  7    | 14     9    | 13 16    12\n12  5 16    | 11  4  2 10 |     3  8  1 | 14  9 15  6\n   15  9    |  5    16    |        4 10 |  7  8     3\n-----------------------------------------------------\n 9  6       | 12 16     5 | 10  4  2 11 |  1  7  3  8\n16 12 13  5 |  4  2 10    |  1  8  7  3 | 15 14  6  9\n 7  8  1  3 |  9 14 15    |  5    13    | 11 10  4  2\n 2  4 10 11 |     7  1  3 | 15  9 14  6 |  5 13 12 16\n\n\u003e @time new_puzzle(5)\n\n   0.510008 seconds (3.77 M allocations: 724.684 MiB, 10.26% gc time)\n\n11    23 14 19 | 22  6  9  3  7 |     2 18       | 10 12        4 | 21     8 17 16\n22 25  8  7 16 | 21 15 23 20 12 |  5  1  4 10 19 |    11 24  2 17 | 18 14  6  3  9\n 5     4 10 12 | 11 17 16 13 25 |     7  8    21 |  3  1  9 14 18 | 15    19     2\n 9 17 13  3 20 |  2 19  1    24 |    16 11 14 25 |  6    22 21    | 23  7  4 10  5\n    2 24    21 | 14  4  5 10  8 |  9 22  6  3 17 |    19 23 16    | 25  1 11 13\n--------------------------------------------------------------------------------\n   20    19 15 |    22 17  9 13 | 25 11 21       |  4 10  6  3    | 14 12 16  2  8\n   21 11     7 |  3     6  4 10 | 17 18          |  2 14  8 12 16 | 20 24  1    15\n18    22  9 17 |        8       |     3  5       | 19 20    24    | 11 21     7 23\n 3 10  5  4  6 | 24  1    19 20 |       16  2 14 |    23     7 11 | 13 18     9 17\n12 14 16  2  8 |  7 23 25 11    | 15 24    19 20 |  9 13 17 18    | 10  3  5  4  6\n--------------------------------------------------------------------------------\n 4  3    24  5 |  1 12 11  8 19 | 13 23 20 15 18 | 17 22 14 10  6 |  2 16 21 25  7\n19 16    11  2 |  4 13  3     5 |        9  6 22 |  1     7 23 15 | 24    17    14\n13    21 17 25 | 10  9  2  6    |  1 19     8 16 |     5  3  4    | 12 23 18 15   \n   15 20  8    | 16       24 18 |  3  4 12 17    |        2 13 21 | 22 10  9    19\n      14  6 22 | 23 20 21 17 15 |    25 24 11  7 |       12 19  9 |  5  4 13  1  3\n--------------------------------------------------------------------------------\n 6    10     4 | 19  2    23 16 |    14 17  1 11 | 18  9 21 22 24 |  3 13     8 25\n14     3 25  9 |  8 11 13 21    | 16 15 23 24 12 |  7  6  1     2 | 19    10 18  4\n 1 19 18 13 11 |  5 10    14  3 |     9  2 25  6 | 23  8 16 15 12 |  7 17 24 21 20\n16  8  2 15 24 |    18 20     1 |  4  5 10 21  3 | 14 17 13 11 19 |  6  9 12    22\n   12  7 21    |  9 24 22 15  6 | 19 20 13 18  8 | 25        5    | 16 11  2 14  1\n--------------------------------------------------------------------------------\n 2  9 19 22    |    21    12 23 | 11 13  7     1 | 15 24 18  8 25 |  4  6 20  5\n      25 16 13 | 20  8 24  1 11 | 10  6 15  5  4 | 12    19 17 14 |  9     3 22 18\n   11 17       |     3 19 22  9 | 18 21 25     2 |  5  4 10    23 |  8 15  7    24\n 7 24 15    18 |  6 25 10  5  4 | 14  8  3 22  9 |     2 20  1 13 |    19 23 11   \n 8  4  6  5 10 | 15  7 18 16    | 20 17    23 24 | 22 21 11  9  3 |  1 25    12\n```\n\n## Solving a puzzle\n\n```julia\n\u003e g = random_puzzle(3, 25)\n\u003e print(g)\n\n2 3   | 4   5 |\n6     |       | 9   4\n    4 | 7     | 8\n---------------------\n      |   5   | 7\n      | 9     |\n      |     8 |   1 3\n---------------------\n      | 1   6 |      \n  4 2 | 8 3   | 6   1\n  6   |       |\n\n\u003e solve!(g)\n\u003e print(g)\n\n2 3 8 | 4 9 5 | 1 6 7\n6 7 5 | 3 8 1 | 9 2 4\n9 1 4 | 7 6 2 | 8 3 5\n---------------------\n4 8 1 | 6 5 3 | 7 9 2\n3 2 7 | 9 1 4 | 5 8 6\n5 9 6 | 2 7 8 | 4 1 3\n---------------------\n8 5 3 | 1 4 6 | 2 7 9\n7 4 2 | 8 3 9 | 6 5 1\n1 6 9 | 5 2 7 | 3 4 8\n\n\u003e g = SudokuGraph(4)\n\u003e print(g)\n\n             |             |             |\n             |             |             |\n             |             |             |\n             |             |             |\n-----------------------------------------------------\n             |             |             |\n             |             |             |\n             |             |             |\n             |             |             |\n-----------------------------------------------------\n             |             |             |\n             |             |             |\n             |             |             |\n             |             |             |\n-----------------------------------------------------\n             |             |             |\n             |             |             |\n             |             |             |\n             |             |             |\n\n\u003e solve!(g)\n\u003e print(g)\n\n16 12 14  3 | 10  6  2 11 |  1  8  4  7 | 13 15  5  9\n 8  4 10  7 |  5 14  9  3 | 12 11 15 13 | 16  1  2  6\n15  2 13  6 |  1  8  7  4 |  5 16  3  9 | 14 11 10 12\n11  1  5  9 | 15 16 12 13 | 10 14  6  2 |  8  3  4  7\n-----------------------------------------------------\n14  5  7  2 | 13  3  6 10 | 15  9  8 12 |  1  4 16 11\n 1  3 11 12 | 16  2  8  9 | 13 10  5  4 |  7 14  6 15\n 4  9  6 15 | 14 12  5  7 |  3  1 11 16 | 10  2  8 13\n13 10 16  8 | 11 15  4  1 |  6  7  2 14 | 12  5  9  3\n-----------------------------------------------------\n 7  6  3 10 |  9  1 16 15 |  2  5 13  8 |  4 12 11 14\n 9 14 15  1 |  8  4 13  5 |  7  6 12 11 |  2 16  3 10\n 5 16  2 11 | 12  7  3 14 |  9  4  1 10 |  6 13 15  8\n12  8  4 13 |  2 10 11  6 | 16  3 14 15 |  5  9  7  1\n-----------------------------------------------------\n10 11  8  5 |  6 13 14  2 |  4 15  9  1 |  3  7 12 16\n 2  7 12 16 |  3  9 15  8 | 14 13 10  5 | 11  6  1  4\n 6 13  9  4 |  7 11  1 12 |  8  2 16  3 | 15 10 14  5\n 3 15  1 14 |  4  5 10 16 | 11 12  7  6 |  9  8 13  2\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosoleve%2Fsudoku-graph-coloring-julia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosoleve%2Fsudoku-graph-coloring-julia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosoleve%2Fsudoku-graph-coloring-julia/lists"}