sven-oly / kenken Goto Github PK
View Code? Open in Web Editor NEWA Python solver for KenKen using rules and patterns
License: Creative Commons Zero v1.0 Universal
A Python solver for KenKen using rules and patterns
License: Creative Commons Zero v1.0 Universal
Due to two bugs in the code, the solver (1) gives the wrong solution to some puzzles, and (2) declares some puzzles solved when they are not.
(1) The problem is in line 194 & 195 of kenken.py; it should read int(...) rather than round(...). Try round(6 / 4) and you'll see why 6 & 4 is a mistaken solution to a 2/ cage.
(2) In check_done(), line 656, the test should be
if len(cell.possibles) > 1 or len(cell.possibles) == 0:
to prevent a mis-declaration of a solution.
Give the details of when and how each set of possible values is reduced, e.g., a singleton removes that value from all others in that row/column. Two equivalent doubles allow removal of those values from others. Same for triples, quadruples, etc.
There's a problem setting the initial configuration, e.g., top row, 3+ cage.
{"width":9,"height":9,"values":[1,2,3,4,5,6,7,8,9],"rules":[{"op":"/","value":3,"cells":[{"x":0,"y":0},{"x":0,"y":1}]},{"op":"-","value":5,"cells":[{"x":1,"y":1},{"x":2,"y":1}]},{"op":"","value":336,"cells":[{"x":3,"y":0},{"x":4,"y":0},{"x":5,"y":0}]},{"op":"+","value":3,"cells":[{"x":6,"y":0},{"x":7,"y":0}]},{"op":"+","value":15,"cells":[{"x":8,"y":0},{"x":7,"y":1},{"x":8,"y":1},{"x":8,"y":2}]},{"op":"-","value":1,"cells":[{"x":5,"y":1},{"x":6,"y":1}]},{"op":"-","value":3,"cells":[{"x":3,"y":1},{"x":4,"y":1}]},{"op":"-","value":2,"cells":[{"x":0,"y":2},{"x":1,"y":2}]},{"op":"-","value":2,"cells":[{"x":2,"y":2},{"x":3,"y":2}]},{"op":"+","value":17,"cells":[{"x":4,"y":2},{"x":4,"y":3}]},{"op":"","value":6,"cells":[{"x":5,"y":2},{"x":5,"y":3}]},{"op":"-","value":8,"cells":[{"x":6,"y":2},{"x":6,"y":3}]},{"op":"-","value":2,"cells":[{"x":7,"y":2},{"x":7,"y":3}]},{"op":"+","value":15,"cells":[{"x":8,"y":3},{"x":8,"y":4},{"x":8,"y":5}]},{"op":"","value":405,"cells":[{"x":8,"y":6},{"x":7,"y":7},{"x":8,"y":7},{"x":8,"y":8}]},{"op":"","value":56,"cells":[{"x":5,"y":7},{"x":6,"y":7}]},{"op":"-","value":2,"cells":[{"x":6,"y":8},{"x":7,"y":8}]},{"op":"+","value":14,"cells":[{"x":3,"y":8},{"x":4,"y":8},{"x":5,"y":8}]},{"op":"/","value":3,"cells":[{"x":1,"y":8},{"x":2,"y":8}]},{"op":"-","value":4,"cells":[{"x":0,"y":7},{"x":0,"y":8}]},{"op":"-","value":1,"cells":[{"x":0,"y":6},{"x":1,"y":6}]},{"op":"-","value":8,"cells":[{"x":1,"y":7},{"x":2,"y":7}]},{"op":"/","value":3,"cells":[{"x":3,"y":7},{"x":4,"y":7}]},{"op":"/","value":2,"cells":[{"x":2,"y":6},{"x":3,"y":6}]},{"op":"/","value":2,"cells":[{"x":4,"y":5},{"x":4,"y":6}]},{"op":"/","value":4,"cells":[{"x":5,"y":5},{"x":5,"y":6}]},{"op":"-","value":5,"cells":[{"x":6,"y":5},{"x":6,"y":6}]},{"op":"-","value":3,"cells":[{"x":7,"y":5},{"x":7,"y":6}]},{"op":"-","value":5,"cells":[{"x":6,"y":4},{"x":7,"y":4}]},{"op":"+","value":12,"cells":[{"x":4,"y":4},{"x":5,"y":4}]},{"op":"+","value":13,"cells":[{"x":3,"y":3},{"x":3,"y":4},{"x":3,"y":5}]},{"op":"","value":72,"cells":[{"x":2,"y":3},{"x":2,"y":4},{"x":2,"y":5}]},{"op":"","value":80,"cells":[{"x":1,"y":3},{"x":1,"y":4},{"x":1,"y":5}]},{"op":"+","value":13,"cells":[{"x":0,"y":3},{"x":0,"y":4},{"x":0,"y":5}]},{"op":"-","value":4,"cells":[{"x":1,"y":0},{"x":2,"y":0}]}]}
Current guessing only goes to on level of guesses of cells with 2 possible values. This could be extended to push a second guess in another cell, and possibly more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.