KenKenVS

Project Started in May 2020. kenkenpuzzle.com
Update as of January 24th, 2021: Single-player has been completely implemented. Multi-player is now in development. Release date TBD.


Demo

User Interface

Below is the current user interface when the user chooses to solve a puzzle. This includes all the functions that you would come to expect from a UI.

Board
To create the board, the frontend receives a KenKen JSON from the backend that is then interpreted by a function that constructs the actual HTML board that you see. This board allows the user to input numbers and notes using the toolbar or the keyboard. I have inputted a few numbers and notes as an example. Note: The board prevents the user from entering numbers outside the range of 1 <= x <= dimension.

Toolbar Buttons

KenKen Generation

Our KenKen database is filled with our own generated puzzles. There are three components to this generation: Latin Square Generation, Cage Generation, Operation Generaion. Together, these three create a random KenKen.

Latin Square Generation
As a reminder, a latin square is a square of size x such that each number 1 - x appears exactly once in each column and row. Given dimension x, we first randomly sort a list of numbers from 1 to x. I'll use 6 as an example for the remainder of this section, but the process is the same for any dimension.

3   1   6   5    4   2   

Then, we fill in each subsequent row of the board with an offset of 1 to ensure that we create a Latin Square in the process.

3   1   6    5   4   2   
165423
654231
542316
423165
231654

Observe that if we switch any two rows or columns, we are still left with a latin square. Therefore our next step is to randomly swap rows and columns. This then leaves us with a random latin square like the one below.

4   3   2    1   6   5   
361452
645213
526341
153624
214536

Cage and Operation Generation
To generate cages, we start in the top left corner of the grid, then randomly "snake" until the snake has nowhere to move. We then restart the snake at a random point then repeat the process. The snakes are then partitioned based on predetermined distributions and these partitions are the cages. For each cage, an operation is generated based on a set distribution. These distributions are chosen whether subtraction and/or division is valid for a cage (addition and multiplication are always valid).