{"id":18152433,"url":"https://github.com/chanioxaris/kenken-solver","last_synced_at":"2025-06-27T00:37:45.987Z","repository":{"id":144416677,"uuid":"96884411","full_name":"chanioxaris/kenken-solver","owner":"chanioxaris","description":"Solves KenKen puzzles, by representing it as a Constraint Satisfaction Problem (CSP)","archived":false,"fork":false,"pushed_at":"2019-03-25T14:51:04.000Z","size":142,"stargazers_count":20,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T08:58:52.612Z","etag":null,"topics":["aima-book","arc-consistency","artificial-intelligence","backtracking","board","constraint-satisfaction-problem","constraints","csp","csp-solver","forward-checking","kenken","minimum-remaining-values","puzzle","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/chanioxaris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2017-07-11T11:07:32.000Z","updated_at":"2024-02-22T15:40:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"22af061c-bda4-49c3-8dd6-914a68e1e04a","html_url":"https://github.com/chanioxaris/kenken-solver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chanioxaris/kenken-solver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fkenken-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fkenken-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fkenken-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fkenken-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanioxaris","download_url":"https://codeload.github.com/chanioxaris/kenken-solver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fkenken-solver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262166443,"owners_count":23269048,"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":["aima-book","arc-consistency","artificial-intelligence","backtracking","board","constraint-satisfaction-problem","constraints","csp","csp-solver","forward-checking","kenken","minimum-remaining-values","puzzle","solver"],"created_at":"2024-11-02T02:07:14.607Z","updated_at":"2025-06-27T00:37:45.978Z","avatar_url":"https://github.com/chanioxaris.png","language":"Python","readme":"## Overview\n\nA program in Python 3.6 that solves [KenKen puzzles](https://en.wikipedia.org/wiki/KenKen), by representing the game as a Constraint Satisfaction Problem (CSP).\n\n\n## Puzzle representation\n\n### Board\nThe KenKen board is represented by a square n-by-n grid of cells. The grid may contain between 1 and n boxes (cages) represented by a heavily outlined perimeter. Each cage will contain in superscript: the target digit value for the cage followed by a mathematical operator. \n\n![kenken](https://github.com/chanioxaris/kenken-solver/blob/master/img/kenken.png)\n\n### Constraints\n\nEach valid solution must follow the below rules:\n\n- The only numbers you may write are 1 to N for a NxN size puzzle.\n- A number cannot be reapeated within the same row.\n- A number cannot be reapeated within the same solumn.\n- In a one-cell cage, just write the target number in that cell.\n- Each \"cage\" (region bounded by a heavy border) contains a \"target number\" and an arithmetic operation. You must fill that cage with numbers that produce the target number, using only the specified arithmetic operation. Numbers may be repeated within a cage, if necessary, as long as they do not repeat within a single row or column.\n\n\n### Input file\n\nThe input format of text file, used to describe a puzzle is:\n\n```\nPuzzle_size\n[Square_indexes1] Cage_operator1 Cage_target1\n[Square_indexes2] Cage_operator2 Cage_target2\n[Square_indexes3] Cage_operator3 Cage_target3\n...\n[Square_indexesM] Cage_operatorM Cage_targetM\n```\n\n\u003cbr /\u003e\n\nFor example, the text representing the above puzzle is:\n\n```\n6\n[(0,0),(1,0)] add 11\n[(0,1),(0,2)] div 2\n[(0,3),(1,3)] mult 20\n[(0,4),(0,5),(1,5),(2,5)] mult 6\n[(1,1),(1,2)] sub 3\n[(1,4),(2,4)] div 3\n[(2,0),(2,1),(3,0),(3,1)] mult 240\n[(2,2),(2,3)] mult 6\n[(3,2),(4,2)] mult 6\n[(3,3),(4,3),(4,4)] add 7\n[(3,4),(3,5)] mult 30\n[(4,0),(4,1)] mult 6\n[(4,5),(5,5)] add 9\n[(5,0),(5,1),(5,2)] add 8\n[(5,3),(5,4)] div 2\n```\n\n\n## Algorithms\n\n### Algorithms information\n\nYou can select among 5 algorithms to solve a puzzle. These are:\n- Backtracking (command line parameter \"BT\").\n- Backtracking with Minimum remaining values (command line parameter \"BT+MRV\").\n- Forward checking (command line parameter \"FC\").\n- Forward checking with Minimum remaining values (command line parameter \"FC+MRV\").\n- Maintaining arc consistency (command line parameter \"MAC\").\n\n\n### Algorithms comparison\n\nThe below table represents the number of assigments used from each algorithm, to solve different size puzzles.\n\n\n|  Size  |   BT   | BT+MRV |   FC   | FC+MRV |   MAC  | \n| :----: | :----: | :----: | :----: | :----: | :----: |\n|   3x3  |   10   |   10   |   9    |   11   |   9    |\n|   4x4  |   33   |   24   |   26   |   18   |   19   |  \n|   5x5  |   89   |   55   |   42   |   33   |   26   |  \n|   6x6  |   947  |   215  |   48   |   68   |   73   |  \n|   7x7  |  2600  |   957  |   278  |   320  |   66   |  \n\n## Usage\n\nFor windows based systems\n`python kenken.py [input file] [algorithm]`\n\n\nFor linux bases systems\n`py kenken.py [input file] [algorithm]`\n\n## References\n\n[Artificial Intelligence: A Modern Approach](http://aima.cs.berkeley.edu/)\n\n[aima-python](https://github.com/aimacode/aima-python)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanioxaris%2Fkenken-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanioxaris%2Fkenken-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanioxaris%2Fkenken-solver/lists"}