Shikaku Solver

Stuck on a Shikaku? Type in its numbers and the solver cuts the grid into rectangles, one at a time if you like, with the reason each one has to go where it does. It also tells you when a puzzle has two answers or none. Fancy a fresh one instead? Play our free Shikaku game.

Built by Brian Hamilton

Grid size

Tap a square and type its number, or pick an example, then press Solve.

Examples
Paste or copy the puzzle as text

Example row: 6 . 4 . . 5. A one-line ID such as 6x6:3d3b3c6a4b5d6h4a2b works too.

How to use the solver, and the rules it follows

Cut the whole grid into rectangles so that every rectangle holds exactly one number and is made of exactly that many squares. No gaps, no overlaps. A square counts as a rectangle.

  • Set the size with Columns and Rows, from 2 to 30 each way. The grid does not have to be square.
  • Tap a square, then type its number on your keyboard or the number pad. For 12, type 1 then 2. Empty square, Backspace or 0 clears it. The arrow keys move between squares.
  • The line under the grid adds the numbers up as you go. They must come to the number of squares in the grid.
  • Solve says whether the puzzle has one answer, more than one, or none. Show next rectangle then draws one rectangle and gives its reason; Show them all draws the lot.
  • Copy link puts the puzzle in a link to share or come back to.

Type the numbers in and watch the total

Set the grid to the size of your puzzle, tap a square and type its number. Most of a Shikaku grid is empty, so there is not much to enter: a 9×9 from our game has about 23 numbers in its 81 squares. If the puzzle is already text, open Paste or copy the puzzle as text instead.

Three ways to give the solver a puzzle. All three describe the 6×6 from our guide.
FormatWhat to typeExample
GridOne row per line, squares separated by spaces or commas; a dot, a dash or 0 for an empty square3 . . . . 3
Compact gridOne character per square. Only when every number is a single digit3....3
One-line IDThe size, then the squares in reading order: a letter stands for a run of empty squares (a is 1, z is 26) and an underscore separates two numbers that touch6x6:3d3b3c6a4b5d6h4a2b

The line under the grid keeps a running total. The rectangles cover every square exactly once and each number is its rectangle's size, so the numbers must add up to the number of squares: 36 on a 6×6, 100 on a 10×10. Get one number wrong and the total is wrong too, because changing a single number always changes the sum. The Does not add up example is the guide puzzle with its 5 typed as a 6.

A number in the wrong square is harder to catch. The total still comes out right. We took 600 puzzles from our game, moved one number in each to the empty square next door, and asked the solver what it thought. In 285 it found no answer, and in 42 it found more than one. In the other 273, nearly half, the puzzle still had exactly one answer: a different puzzle, and a perfectly good one.

So if the solver's answer looks nothing like the grid you have half finished, check where each number sits, not only what it says.

Three rules do most of the work

The solver does not hunt for the answer blindly and then read it back to you. It works the way you would, with three rules, and Show next rectangle tells you which one it used. All three are about rectangles that fit a number: the right size, on the grid, holding that number and no other, and not overlapping anything already drawn.

  1. One rectangle fits. Draw it. Each rectangle drawn takes squares away from its neighbours, so this rule keeps firing.
  2. Only one number can reach a square. That number's rectangle has to cover the square, which often leaves it a single choice.
  3. A rectangle would cut a square off. If drawing it leaves some square that no number could reach any more, it is wrong. Rule it out.

Here is the 6×6 from our Shikaku strategy guide, numbered in the order the solver drew it. The first two rules were enough.

The order the solver drew the nine rectanglesThe six by six puzzle from the Shikaku guide, solved, with each rectangle numbered in its top-left corner in the order it was drawn. One: the 3 in row 1, column 1, 3 wide by 1 tall, the only rectangle that fitted from the start. Two: the 3 in row 1, column 6, 3 wide by 1 tall, the only rectangle that fitted from the start. Three: the 5 in row 3, column 6, 1 wide by 5 tall, the only rectangle that fitted from the start. Four: the 4 in row 6, column 2, 2 wide by 2 tall, forced by a square only it could reach. Five: the 6 in row 3, column 1, 2 wide by 3 tall, the last rectangle that still fitted. Six: the 3 in row 2, column 3, 3 wide by 1 tall, the last rectangle that still fitted. Seven: the 6 in row 4, column 5, 2 wide by 3 tall, forced by a square only it could reach. Eight: the 4 in row 3, column 3, 1 wide by 4 tall, the last rectangle that still fitted. Nine: the 2 in row 6, column 4, 2 wide by 1 tall, the last rectangle that still fitted.
Rectangles 1 to 3 were the only ones that fitted from the start. 4 and 7 came from a square only one number could reach. The other four were each the last rectangle that still fitted once their neighbours were drawn.

That mix is typical. Across 1,500 puzzles from our game, 100 at each size and difficulty, the solver drew 43,413 rectangles and recorded the rule behind each one:

Which rule found each of 43,413 rectangles in 1,500 puzzles from our Shikaku game.
How the rectangle was foundRectanglesShare
Rule 1: the only one that fitted from the start6,82715.7%
Rule 1: the only one that still fitted23,11953.3%
Rule 2: a square only it could reach12,35128.5%
Rule 3: the others cut a square off7741.8%
None of the three: a trial3420.8%

The third rule: do not cut a square off

Rule 3 is the one people miss, because nothing on the board points at it. Load the 7×7, all three rules example and step through. Three rectangles go down easily. Then the 5 in the top row has two rectangles that fit, both strips lying along the top edge, and neither of the first two rules can choose between them.

The strip moved one square right cuts off the cornerA seven by seven puzzle with three rectangles drawn. The 5 in the top row could be a strip of five squares along the top edge in two positions. This one, shown dashed, starts in the second column. It leaves the top-left corner square, marked with a cross, out of reach of every number.
Slide the strip one square to the right and the top-left corner is cut off: the 4 below it was the only other number that could reach, and the strip now blocks it.
The strip that starts in the cornerThe same puzzle. The strip of five now starts in the top-left corner and is drawn solid, and the 4 below it takes the next four squares of the second row.
So the strip starts in the corner. The 4 is then left with one rectangle that fits, and the rest of the grid follows by rule 1.

When you are stuck on a puzzle of your own, this is the check to run by hand: take a number with two or three rectangles left, picture each one drawn, and look for a square left stranded beside it. Corners and edges are where it happens most, because fewer numbers can reach them.

When the rules run out, the solver tries and backs out

Sometimes none of the three rules applies. The solver then takes the number with the fewest rectangles left, tries each in turn, and follows the consequences until all but one break down. It says so plainly when it does this, because there is no neat reason to give you. It is not a blind guess, though: a puzzle with one answer always lets you rule the wrong rectangles out. You just have to look further ahead than one square.

How far each rule gets, on 300 puzzles from our game at each size (100 Easy, 100 Medium, 100 Hard).
GridRules 1 and 2 finished itNeeded rule 3Needed a trial
5×529334
7×72632314
9×92234631
11×111747551
14×141179489

Size matters more than the difficulty setting. The first two rules finished 414 of the 500 Easy puzzles, 349 of the Medium and 307 of the Hard. Even so, a puzzle that needs a trial rarely needs many: 342 rectangles out of 43,413, and never more than 7 in one puzzle.

When the grid can be cut two ways, or not at all

The solver does not stop at the first way of cutting the grid up. It keeps looking for a second, and the verdict tells you what it found.

What each verdict means, and the usual cause when it is not the one you wanted.
VerdictWhat it meansIf you expected one answer
One answerNo other set of rectangles fits every number. The puzzle is sound.—
More than one answerAt least two sets fit. The shaded squares are where they differ, and you can flip between them.A number is in the wrong square
No answer: does not add upThe numbers do not total the number of squares.A number is wrong or missing, or the grid is the wrong size
No answer: names a number or squareThat number has no rectangle that fits, or nothing can reach that square.Look at the numbers around the place it names

The Two answers example started as a sound 5×5 from our game. Moving one 2 up a square was enough to break it:

First answer: the two 2s as upright dominoesA five by five puzzle cut into eight rectangles. Two 2s sit at opposite corners of a two by two block near the left edge. Here the block is cut down the middle into two upright dominoes.
One answer: the two 2s stand side by side as upright dominoes.
Second answer: the same block cut acrossThe same puzzle with the same eight numbers. The two by two block is cut across instead, into two flat dominoes. The other six rectangles have not changed.
The other: the same four squares, cut across instead. Every other rectangle is the same in both.

That shape is worth knowing: two 2s at opposite corners of a 2×2 block that they fill between them can always be cut two ways. A puzzle with one answer cannot contain it, so when the solver shades a block like this, one of those numbers belongs somewhere else.

When there is no answer, the solver tries to say where it goes wrong. In the copying test above, 281 of the 285 no-answer verdicts named a number with no rectangle left or a square nothing could reach.

Big grids, oblong grids and IDs from other apps

The grid can be any size from 2×2 to 30×30 and does not have to be square. Size is not a problem for speed: we timed 50 single-answer 30×30 grids with about 150 numbers each, and the solver took under a hundredth of a second on a typical one and under a tenth on the slowest. Everything runs in your browser, and the verdict shows how long your own puzzle took.

The one-line ID in the table above is the same game ID that the Rectangles puzzle in Simon Tatham's Portable Puzzle Collection uses, so an ID copied from that program can be pasted straight in. Copy link uses it too, which keeps links short enough to send.

Shikaku, Rectangles, Divide by Squares

Shikaku was first published by the Japanese puzzle magazine Nikoli. In English the same puzzle appears as Rectangles, Divide by Squares and Divide by Box. The rules are identical under every name, so the solver works for all of them.

A fresh grid to play, and solvers for other puzzles

Our free Shikaku game deals puzzles from 5×5 to 14×14 at three difficulties, and every one is checked by this solver before you see it. That check matters more than you might expect: at 14×14 Easy only about 1 in 190 of the layouts it tries has a single answer, and the rest are thrown away. Building the solver also fixed a fault in the game. It used to give up after 300 layouts, which at 14×14 Easy happened on 12 of 40 requests we measured and left the page stuck on “Generating puzzle”.

For other puzzles, the KenKen solver works from cages and the Sokoban solver finds the fewest pushes. The rest, including best move calculators for Checkers and Gomoku, are on the calculators page. If you like cutting a grid into regions, Galaxies and Nurikabe use the same instinct with different shapes.