LETTER PUZZLE (16K ZX-81)
by Joao Campos
from ZX Computing (February/March 1986), pages 118-119

A beautiful presentation of the block puzzle game from Joao Campos of
Portugal.

I have used letters in this version rather than the more often used numbers,
the main reason being that each square is represented by only one character,
and this means it is easier to identify for moving.

Once you have ENTERed and SAVEd the final version and you have RUN the
program then, after the title page has been displayed, you have the option
of choosing from two solutions of the puzzle. You may choose solution number
one, or two, or, by pressing 0, take any of the two (lines 1000-1220). The
computer then shuffles the letters (this is done in FAST mode - lines
600-900) and displays the initial disposition of the board (2500-2540).

Now, using the cursor keys, you move the letters around (obviously you can
only move each letter horizontally or vertically into the empty square).
This is dealt with in lines 100-370. The moves you make are counted, and a
hi-score (or rather a low-score) is kept for finding the solution in the
least possible moves.

You will find that there are some initial settings that do not allow for a
proper solution; that's when the last three letters are M-O-N instead of
M-N-O; in this case, either press the "F" key to restart the game, or wait
for the computer to tell you that the solution is impossible (lines
5000-5010) and invite you to restart (lines 4140-4170).


A$ and B$    The two possible solutions.
C$           Set of the 15 letters + space.
D$           Auxiliary set, to load L$ randomly.
G$ and H$    The two "solution impossible" configurations.
I and J      Loop control variables.
K$           INKEY$ hold.
L$           Letter disposition in the board.
M            Original position of the moved letter.
R            Random pointer to C$ and D$.
RCD          Hi-score.
S            Moves counter.
S$           Initial option (0, 1 or 2).
V            Empty position in the board.
X and Y      Printing coordinates (column and line).

This program is about 5.7K long.