You may also like

problem icon


This practical challenge invites you to investigate the different squares you can make on a square geoboard or pegboard.

problem icon


This activity investigates how you might make squares and pentominoes from Polydron.

problem icon

Multilink Cubes

If you had 36 cubes, what different cuboids could you make?


Stage: 2, 3, 4 and 5 Challenge Level: Challenge Level:3 Challenge Level:3 Challenge Level:3

Thank you Tim from Gravesend Grammar School for your solution.

The solutions are 312132 and its mirror image 231213. We call these 3-sandwiches.

You cannot do the same with only ones and twos, because between the two twos there must be two digits, which have to be ones as these are the only available digits, but that means that between the two ones there are no digits, so this is not possible.

The only 4-sandwiches are 41312432 (and its mirror image).

You will probably have found quite a lot of 7-sandwiches because there are altogether 26 (and their mirror images).

You may have tried, and failed, to find 5-sandwiches and 6-sandwiches but there aren't any. If you have tried to find 8-sandwiches you will probably have had more success as there are altogether 150 of these (and their mirror images).

See 'Impossible Sandwiches' for a simple proof that n-sandwiches can only be made when n=4m or n=4m-1 (for integers n and m). For example solutions do not exist for n=5 or n=6 but solutions do exist for n=7 and 8.

The following BASIC program gives the 4-sandwiches. You could try making some small changes to get the 7-sandwiches. Alternatively you could take up the challenge of finding all the solutions without using a computer, or write a computer program in a different language to find the solutions.

10      DIM A(8)
20      FOR A(1)= 1 TO 6:       REM A(1) and A(5) are positions for 1's
30      FOR A(2)= 1 TO 5:       REM A(2) and A(6) are positions for 2's
40      FOR A(3)= 1 TO 4:       REM A(3) and A(7) are positions for 3's
50      FOR A(4)= 1 TO 3        REM A(4) and A(8) are positions for 4's
60      FOR T=1 TO 4
70      A(T+4)= A(T) + T + 1:   REM Second positions of 1 to 4 spaced correctly from the first
80      NEXT
100     IF Z = 1 PROCPRINT
120     END

140     Z=1:            REM Z=0 eliminates cases where two numbers occur in same position
150     FOR I=1 TO 7    
160     FOR J=I+1 TO 8  
170     IF Z=0 GOTO 200 
180     IF A(I)=A(J) THEN Z=0
190     NEXT: NEXT
200     ENDPROC

220     FOR M=1 TO 8
230     FOR K=1 TO 8
240     IF A(K)=M AND K < 5 PRINT K;
250     IF A(K)=M AND K > 4 PRINT K- 4;
260     NEXT: NEXT
270     PRINT
280     ENDPROC

There are no N-sandwiches for N=1, 2, 5, 6 or 9 or any number that leaves a remainder of 1 or 2 when divided by 4. (Click here for a proof of this fact.)