KenKen in Proloq KenKen is a mathematics game similar to Sudoku, in which a N ×
ID: 3841345 • Letter: K
Question
KenKen in Proloq
KenKen is a mathematics game similar to Sudoku, in which a N × N grid of numbers must be solved so that each square contains a number from 1 up to N. As in Sudoku, every row and column of KenKen can contain a particular number only once, and every number from 1 to N must be in each row and column. KenKen does not use the 3 x 3 squares uniqueness rule of Sudoku; instead, each KenKen puzzle breaks up the squares into various irregular “cages”, and in each cage a single target value and a single operator is placed. When the operator is applied to the squares of the cage, the given value is obtained. The order that the operator is applied to the squares is not fixed, which is important for division and subtraction. See Wikipedia for an explanation.
Adapt the Sudoku solver from lecture to solve the KenKen puzzle given here: http://www.calcudoku.org/en/2016-11-29/6/3.
You need to retain the code that forces unique values for each entry in a row/column, but do not need the 3 x 3 squares code. You will need to directly encode the values and operators for each cage into the logic itself. For example, if the first two squares in the first row are a cage with 3+ written in the puzzle, then you would need a relation forcing the sum of A1 and A2 to be 3.
Implementation notes:
1. The library clpfd used in the Sudoku solver will be needed here. This library uses its own syntax for checking arithmetic values for equality. Do not use is or = for enforcing cage constraints; you need to use #=.
2. If a cage is marked 3-, then you will need an OR relation because the order of the squares is not xed, e.g. (A1 - A2 #= 3; A2 - A1 #= 3). Likewise for division.
Explanation / Answer
DO THUMBS UP ^_^
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.