On my phone (running Android) and my Windows laptop I have installed a set of puzzles called Simon Tatham's Portable Puzzle Collection (hereafter referred to as STPPC). One of those puzzles, Keen is the same as a Japanese puzzle called KenKen. You get a grid, say 5x5 in size. Every digit from 1 to 5 must be in every row and every column (in essence a magic square). Regions consisting of one or more squares are defined and can be of irregular shapes and sizes).

Some time later, I was given a book containing a bunch of KenKen puzzles, and rather than try to solve them in the book (e.g. having to use pencil and possibly using an eraser when making mistakes), I'd prefer to solve them in STPPC.

Within STPPC you can enter a game ID which is a way to encode the starting grid of a puzzle. I've worked out how the first part of the encoding works (which describes the lines defining regions of the grid), but in the second part it provides a value and an arithmetic sign (plus, minus, times or divide) which provides you with the answer and the sign used to determine the sum used, which should help you to work out the values in each separate square of the region.

For example, a puzzle could be a 5x5 grid, one of the regions could be two squares in size and have an answer of 12x, indicating the digits could be a 3 and a 4 only (since you can only have the digits 1-5 in a row or column).

Here's the layout of the first puzzle of my book. I hope the ASCII art works:

Code: Select all

```
Puzzle 1
+=====+=====+=====+=====+=====+=====+
|30X |1- ' |1- ' |3- |
| | ' | ' | |
+ - - +=====+=====+=====+=====+ - - +
| ' |14+ ' |4 | |
| ' | ' | | |
+=====+=====+=====+ - - +=====+=====+
|5+ ' |3- | |3/ |5- |
| ' | | | | |
+=====+=====+ - - +=====+ - - + - - +
|1- |3/ | |48X | | |
| | | | | | |
+ - - + - - +=====+ - - +=====+=====+
| | | ' |15X |9+ |
| | | ' | | |
+=====+=====+=====+=====+ - - + - - +
|2 |2/ ' | ' | |
| | ' | ' | |
+=====+=====+=====+=====+=====+=====+
```

The source code of STPPC is available and I've been through it a few times. Here's the code for this particular puzzle.

If you search within the code for the word inelegant, it should return two results. The second one seems to hold a clue. Maybe it has to be a + or -, or am I barking up the wrong tree?

If anyone gets the chance to try encoding the puzzle supplied into the format required by the Game ID to get the grid into the puzzle, that would be great. It would at least tell me if I am right so far with my understanding of the encoding used.

One last thing. I like these puzzles so much I am now wondering if there's any way to get them up and running on a Beeb, but I don't even really know the ins and outs of C enough to know if that's doable or not.