A helper for solving substitution ciphers on a 1K ZX80. The program prints the coded quotation with a dash under each letter you have not yet solved. Answer COMMAND with F to see how often each letter occurs, or with X=L to say that the coded letter X stands for L; the quotation is reprinted with every solved letter filled in. The article lists the usual frequency order of English letters, ETAONRISHDLFCMUGYPWBVKXJQZ, as a starting point.
To set a new puzzle, change the quotation in line 990, keeping it no longer than the one printed so the display fits in 1K. The answer to the printed puzzle appeared in the next issue.
Published in Syntax November 1980 (Cryptoquote — Use Your ZX80 to Help You Solve Substitution Ciphers).
Source Code
6 DIM T(25)
7 LET K=1000
60 FOR X=0 TO 25
65 LET T(X)=220
70 NEXT X
100 CLS
110 GO SUB 990
120 PRINT T$
123 LET X=CODE(T$)
125 IF X<38 OR X>63 THEN GO TO 170
130 PRINT CHR$(T(X-38));
140 LET T$=TL$(T$)
160 GO TO 123
170 IF X=1 THEN GO TO 200
175 PRINT CHR$(X);
180 GO TO 140
200 PRINT
205 PRINT "COMMAND:";
210 INPUT F$
220 IF CODE(TL$(F$))=227 THEN LET T(CODE(F$)-38)=CODE(TL$(TL$(F$)))
222 IF F$="F" THEN GO TO 400
240 GO TO 100
400 CLS
410 GO SUB 990
460 LET N=CODE(T$)-38
470 IF N=-37 THEN GO TO 500
480 IF N<0 OR N>25 THEN GO TO 485
483 LET T(N)=T(N) + K
485 LET T$=TL$(T$)
490 GO TO 460
500 FOR X=0 TO 12
505 LET S=T(X)-(T(X)/K)*K
506 LET S2=T(X+13)-(T(X+13)/K)*K
510 PRINT CHR$(X+38);"(";CHR$(S);"):";T(X)/K;" ";CHR$(X+51);"(";CHR$(S2);"):";T(X+13)/K
520 LET T(X)=S
525 LET T(X+13)=S2
530 NEXT X
540 GO TO 200
990 LET T$="UVQ JVQQXZX KQ JQYGZKZ UBKV YWJVBPZX WJJZGKX KVZ JQPMBKBQPX QC XFWDZLH"
999 RETURNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

