Building New Words
Join strings with + to build words character by character, then reverse a word on coloured tiles.
Slicing takes strings apart. Concatenation puts them back together. Together, they let you rearrange letters — which is exactly what the scramble algorithm needs.
The + Operator
10 LET a$="spec"
20 LET b$="trum"
30 LET r$=a$+b$
40 PRINT a$;" + ";b$;" = ";r$
50 PRINT
60 LET w$="hello"
70 LET r$=""
80 FOR i=1 TO LEN w$
90 LET r$=r$+w$(i TO i)
100 PRINT "Building: ";r$
110 NEXT i
When used with strings, + joins them end to end. "spec" + "trum" produces "spectrum". This is called concatenation.
The second part of the program builds a word character by character. Starting with an empty string r$, each pass through the loop takes one character from w$ and appends it: LET r$ = r$ + w$(i TO i). After all passes, r$ contains the complete word — built one letter at a time.
Reversing a Word
5 BORDER 0: PAPER 0: INK 7: CLS
10 FOR i=0 TO 31
12 PRINT AT 0,i; PAPER 2;" "
14 NEXT i
16 PRINT AT 0,8; PAPER 2; INK 7; BRIGHT 1;" WORD SCRAMBLE "
20 LET w$="castle"
22 LET c=(32-LEN w$*2)/2
24 PRINT AT 3,10; INK 5;"Original:"
26 FOR i=1 TO LEN w$
28 PRINT AT 5,c+i*2-2; PAPER 1;" "
30 PRINT AT 6,c+i*2-2; PAPER 1;" "
32 NEXT i
34 FOR i=1 TO LEN w$
36 PRINT AT 5,c+i*2-2; PAPER 1; INK 6; BRIGHT 1;w$(i TO i)
38 BEEP 0.05,5+i*2
40 NEXT i
42 PAUSE 50
44 PRINT AT 9,10; INK 5;"Reversed:"
46 LET r$=""
48 FOR i=LEN w$ TO 1 STEP -1
50 LET r$=r$+w$(i TO i)
52 NEXT i
54 FOR i=1 TO LEN r$
56 PRINT AT 11,c+i*2-2; PAPER 3;" "
58 PRINT AT 12,c+i*2-2; PAPER 3;" "
60 NEXT i
62 FOR i=1 TO LEN r$
64 PRINT AT 11,c+i*2-2; PAPER 3; INK 7; BRIGHT 1;r$(i TO i)
66 BEEP 0.05,20-i*2
68 NEXT i

The original word “castle” appears on blue tiles with the ascending reveal. Then, after a pause, the reversed word “eltsac” appears on magenta tiles below — built by looping backwards through the original: FOR i = LEN w$ TO 1 STEP -1.
The descending pitch (20 - i * 2) mirrors the descending direction. The two rows of tiles — blue for the original, magenta for the reversed — show that the same letters can be rearranged into something different.
The Scramble Pattern
This is exactly how the scramble algorithm will work, with one difference: instead of going backwards through the word, it picks letters at random positions. The building loop is the same — start empty, append one character at a time until every letter has been used.
- Start with an empty result string
s$ - Pick a random position
pin the temporary stringt$ - Append
t$(p TO p)tos$ - Remove position
pfromt$ - Repeat until
t$is empty
Try This
Reverse any word. Add INPUT "Word? "; w$ at the start and remove the hardcoded word. Type any word and see it reversed on tiles.
Palindrome checker. After building the reversed string, compare it to the original: IF r$ = w$ THEN PRINT "Palindrome!". Try “level”, “racecar”, and “hello”.
What You’ve Learnt
- Concatenation —
+joins strings:"ab" + "cd"produces"abcd" - Building in a loop — start with
"", append one character per pass - STEP -1 —
FOR i = LEN w$ TO 1 STEP -1loops backwards - Two tile rows — different
PAPERcolours distinguish original from transformed