{"id":16852826,"url":"https://github.com/avdeev/sudoku","last_synced_at":"2025-03-18T10:17:14.231Z","repository":{"id":24549042,"uuid":"27955871","full_name":"avdeev/sudoku","owner":"avdeev","description":"Generating Sudoku, the heuristic algorithm for solving algorithm and exhaustive search.","archived":false,"fork":false,"pushed_at":"2014-12-13T09:59:04.000Z","size":260,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T16:36:38.242Z","etag":null,"topics":["heuristic-algorithm","sudoku","sudoku-game","sudoku-generator"],"latest_commit_sha":null,"homepage":"http://avdeev.github.io/sudoku","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avdeev.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}},"created_at":"2014-12-13T09:26:10.000Z","updated_at":"2023-04-23T01:09:57.000Z","dependencies_parsed_at":"2022-08-23T01:21:13.031Z","dependency_job_id":null,"html_url":"https://github.com/avdeev/sudoku","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/avdeev%2Fsudoku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdeev%2Fsudoku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdeev%2Fsudoku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdeev%2Fsudoku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avdeev","download_url":"https://codeload.github.com/avdeev/sudoku/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244198395,"owners_count":20414443,"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":["heuristic-algorithm","sudoku","sudoku-game","sudoku-generator"],"created_at":"2024-10-13T13:48:52.006Z","updated_at":"2025-03-18T10:17:14.203Z","avatar_url":"https://github.com/avdeev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sudoku\nGenerating Sudoku, the heuristic algorithm for solving algorithm and exhaustive search.\n\nThe application allows you to test the running time of algorithms on collections of sudoku.\n\n## Demo\nhttp://avdeev.github.io/sudoku\n\n## Implemented algorithms\n\n### Generating sudoku\n```js\n  this.generate = function(cellEmptyInput) {\n    this.refreshSudoku();\n\n    for (var i = 0; i \u003c this.getRandomInt(1, 9); i++) {\n      this.transposeRowBig(this.getRandomInt(0, 2), this.getRandomInt(0, 2));\n    }\n    \n    for (var i = 0; i \u003c this.getRandomInt(1, 9); i++) {\n      this.transposeColumnBig(this.getRandomInt(0, 2), this.getRandomInt(0, 2));\n    }\n\n    for (var i = 0; i \u003c this.getRandomInt(3, 27); i++) {\n      var multiplier = this.getRandomInt(0, 2);\n      this.transposeRow(this.getRandomInt(0, 2) + 3 * multiplier, this.getRandomInt(0, 2) + 3 * multiplier);\n    }\n\n    for (var i = 0; i \u003c this.getRandomInt(3, 27); i++) {\n      var multiplier = this.getRandomInt(0, 2);\n      this.transposeColumn(this.getRandomInt(0, 2) + 3 * multiplier, this.getRandomInt(0, 2) + 3 * multiplier);\n    }\n\n    this.removeElements(cellEmptyInput);\n    return this.sudoku;\n  }\n```\n\n### Heuristic algorithm\n#### Method \"Single\"\n```js\n  function solveSingle(i, j) {\n    solved[i][j][2] = arrayDiff(solved[i][j][2], rowContent(i));\n    solved[i][j][2] = arrayDiff(solved[i][j][2], colContent(j));\n    solved[i][j][2] = arrayDiff(solved[i][j][2], sectContent(i, j));\n    if ( 1 == solved[i][j][2].length ) {\n      // Исключили все варианты кроме одного\n      markSolved(i, j, solved[i][j][2][0]);\n      return 1;\n    }\n    return 0;\n  };\n```\n\n#### Method \"Hidden Single\"\n```js\n  function solveHiddenSingle(i, j) {\n    var less_suggest = lessRowSuggest(i, j);\n    var changed = 0;\n    if ( 1 == less_suggest.length ) {\n      markSolved(i, j, less_suggest[0]);\n      changed++;\n    }\n    var less_suggest = lessColSuggest(i, j);\n    if ( 1 == less_suggest.length ) {\n      markSolved(i, j, less_suggest[0]);\n      changed++;\n    }\n    var less_suggest = lessSectSuggest(i, j);\n    if ( 1 == less_suggest.length ) {\n      markSolved(i, j, less_suggest[0]);\n      changed++;\n    }\n    return changed;\n  };\n```\n\n#### Exhaustive search\n\n```js\n  function solve() {\n    unknownI = 0;\n    unknownJ = 0;\n\n    getNextUnknownCell();\n    while(!isSolved() || !checkSudoku()) {\n\n      while(!checkSudoku() \u0026\u0026 solved[unknownI][unknownJ][0] \u003c 10) {\n        incUnknownCell();\n        checked++;\n      }\n\n      if (solved[unknownI][unknownJ][0] \u003c 10) {\n        getNextUnknownCell();\n      } else {\n        getPreviousUnknownCell();\n      }\n    }\n  };\n```\n\n## Vendors\n\n* Bootstrap.js 2.3.1\n* jQuery v1.9.1\n* Modernizr 2.6.2","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favdeev%2Fsudoku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favdeev%2Fsudoku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favdeev%2Fsudoku/lists"}