Jaap's Puzzle Page

Jushbox

Jushbox

Jushbox is a puzzle that consists of a box containing nine stacks of pieces, arranged in a 3×3 grid. Each stack is supported underneath by a spring, very similar to coin dispensers. Each stack can hold up six pieces. The top piece of any non-empty stack can slide to the top of any adjacent stack, provided that adjacent stack does not already hold 6 pieces.
At the start, every stack has three pieces. They come in 3 colours (yellow, red, and blue), and the three columns of stacks each have a different colour. You can set yourself various objectives, such as changing the order of the coloured columns, or rearranging the pieces so that the rows are different colours instead of the columns, or making the layers different colours. This is generally not very difficult, so you may try to minimise the number of moves you need for these tasks. For each stack, only the colour of the top piece is visible, so the puzzle apparently trains your memory.

The number of positions:

There is no simple formula for calculating the number of positions of this puzzle generally. Suppose the 27 pieces were all of the same colour. We need to find out how many ways there are to distribute 27 pieces into 9 stacks which each contain any number between 0 and 6 pieces inclusive. This can be calculated recursively. Let N(p,s) be the number of ways we can distribute p pieces into s stacks with at most 6 in any stack. The following equation then holds:

N(p,s+1) = N(p,s)+N(p-1,s)+N(p-2,s)+N(p-3,s)+N(p-4,s)+N(p-5,s)+N(p-6,s)

This counts the number of ways we to make s+1 stacks by counting all the positions that are possible before we added the 0 to 6 pieces that form the last stack. Using the trivial boundary conditions that N(0,0)=1 and N(p,0)=0 for non-zero values of p we can then find the value of N(27,9) by building the following table:

Stacks
pcs0123456789
0111 1 1 1 1 1 1 1
1012 3 4 5 6 7 8 9
2013 6 10 15 21 28 36 45
301410 20 35 56 84 120 165
401515 35 70 126 210 330 495
501621 56 126 252 462 792 1,287
601728 84 210 462 924 1,716 3,003
700633116 325 786 1,709 3,424 6,426
800536149 4701,251 2,954 6,371 12,789
900437180 6401,876 4,809 11,152 23,905
1000336206 8262,667 7,420 18,488 42,273
11002332241,0153,61210,906 29,184 71,127
12001282311,1904,67615,330 44,052 114,387
13000212241,3305,79620,664 63,792 176,463
14000152061,4206,89126,769 88,852 261,891
15000101801,4517,87233,390119,288 374,808
16000 61491,4208,65240,166154,645 518,301
17000 31161,3309,15646,655193,880 693,693
18000 1 841,1909,33152,374235,348 899,857
19000 0 561,0159,15656,854276,8721,132,677
20000 0 35 8268,65259,710315,9181,384,803
21000 0 20 6407,87260,691349,8401,645,791
22000 0 10 4706,89159,710376,1601,902,663
23000 0 4 3255,79656,854392,8482,140,866
24000 0 1 2104,67652,374398,5672,345,553
25000 0 0 1263,61246,655392,8482,503,053
26000 0 0 702,66740,166376,1602,602,341
27000 0 0 351,87633,390349,8402,636,263

Each number in the table is the sum of the number directly to its left and the six numbers above that. So there turn out to be 2,636,263 configurations for the 27 pieces in the box, ignoring colours.

There are 27 pieces, 9 of each colour, so for each of the stack configurations there are 27!/9!3 possible arrangements of the colours. This gives a total of 2,636,263 · 27!/9!3 = 600,734,296,146,484,500 positions.


Solutions:

This puzzle is easy to solve. You merely have to solve the bottom layer of a stack first, and only then the middle layer and finally top layer. This is done by emptying the stack, and then putting the pieces in to the empty stack in the correct order. Any solved stacks can still be used as repositories for spare pieces.

The number of positions of the puzzle as a whole is too large to calculate optimal solutions for, but it is easy to do so for three stacks that form a row. This gives some fairly short solutions for some of the transformations between nice positions. Some of these are shown below.

Swapping two adjacent columns
You can swap two adjacent stacks in 12 moves. This is very straightforward: Move all three middle pieces of a row to the right, move all three left pieces to the middle, and then the first three pieces from the right all the way to the left. This swaps the left two stacks of a row.
You can do this once in each row to swap left two adjacent columns in 36 moves. Swapping two adjacent stacks cannot be done in fewer than 12 moves if you only do moves within one row. It may be that using moves between rows can reduce the number of moves to fewer than 36, but I don't believe that to be the case.

Cyclically permuting all three columns
Simply use the method above to swap the left two columns, and then repeat it in mirror image to swap the right two columns.
Again, if you only allow moves within each row, then the 72 moves cannot be reduced. This time it is definitely possible to shorten the move sequence by using moves between rows, as follows:

  1. Move one piece from the middle stack to the adjacent row.
  2. Move the remaining two middle pieces to the left stack.
  3. Move the three pieces in the right stack to the middle.
  4. Move two pieces from the left stack back to the middle.
  5. Move the three pieces from the left stack one by one over to the right stack.
  6. Move two pieces from the middle stack to the left.
  7. Finally, move the piece that was removed in step a back into this row and into the left stack.

This uses a total of 18 moves instead of 24, giving a total of 54 moves to permute the three columns. I do not know if this can be improved further.

Swapping the two outer (non-adjacent) columns
If you only use moves within one row, then it takes 22 moves to swap the two outer stacks, so 66 moves to swap the two outer columns. Here are the 22 moves.

  1. Move one piece from the right to the middle.
  2. Move one piece from the left over to the right.
  3. Move one piece from the middle to the right.
  4. Move two pieces from the left to the middle.
  5. Move one piece from the right over to the left.
  6. Move two pieces from the middle to the left.
  7. Move two pieces from the right to the middle.
  8. Move three pieces from the left over to the right, one by one.
  9. Move two pieces from the middle to the left.

Again however, you can do this more easily and in fewer moves by temporarily putting one piece in another row.

  1. Move one piece from the middle stack to the adjacent row.
  2. Move three pieces from the right to the middle.
  3. Move three pieces from the left over to the right, one by one.
  4. Move three pieces from the middle to the left.
  5. Finally, move the piece that was removed in step a back into this row in the middle stack.

This uses a total of 14 moves instead of 22, giving a total of 42 moves to swap the outer columns. I do not know if this can be improved further.

Changing three columns into three layers
If you only use moves within one row, then it takes 20 moves to rearrange the 9 pieces into three layers, giving 60 moves to make layers in the whole box. Here are the 20 moves:

  1. Move three pieces from the middle to the right.
  2. Move one piece from the left over to the right.
  3. Move one piece from the left to the middle.
  4. Move two pieces from the right to the middle.
  5. Move one piece from the left to the middle.
  6. Move four pieces from the right over to the left, one by one.
  7. Move two pieces from the middle to the right.
  8. Move one piece from the left over to the right.
  9. Move one piece from the left to the middle.

Again however, you can do this more easily and in fewer moves by temporarily putting one piece in another row.

  1. Move one piece from the right stack to the adjacent row.
  2. Move three pieces from the middle to the right.
  3. Move one piece from the left to the middle.
  4. Move two pieces from the right to the middle.
  5. Move one piece from the left to the middle.
  6. Move three pieces from the right over to the left, one by one.
  7. Move two pieces from the middle to the right.
  8. Move one piece from the left to the middle.
  9. Finally, move the piece that was removed in step a back into this row in the right stack.

This uses a total of 18 moves instead of 20, giving a total of 54 moves to change columns to layers. I do not know if this can be improved further.