Reverse

Developer(s): Bill Eckel
Date: 1981
Type: Program
Platform(s): ZX80
Tags: Game

The program shows a list of the digits 1 to 9 in random order. Answer NO. TO REVERSE with a number from 1 to 9 and that many digits, counted from the left, are reversed. Get the list into order 1 to 9 and it tells you how many moves you took and offers another game; 0 makes a new list.

Syntax added changes for the 8K ROM (lines 100, 120, 260 and 310), with a note that the game then needs more than 1K.

Published in Syntax November 1981 (Reverse).

Related Articles

The object of this game, rewritten from one published by Creative Computing, is to get the numbers in ascending order from left to right.

Image Gallery

Source Code

  30 LET N=9
  40 DIM A(N)
  50 LET T=0
 100 LET A(1)=RND(N-1)+1
 110 FOR K=2 TO N
 120 LET A(K)=RND(N)
 130 FOR J=1 TO K-1
 140 IF A(K)=A(J) THEN GO TO 120
 150 NEXT J
 160 NEXT K
 210 GO SUB 600
 220 PRINT
 230 PRINT "NO. TO REVERSE"
 240 INPUT R
 250 IF R=0 THEN GO TO 50
 260 IF R=N OR R<N THEN GO TO 300
 265 PRINT
 270 PRINT "OOPS TOO MANY"
 280 GO TO 240
 300 LET T=T+1
 310 FOR K=1 TO R/2
 320 LET Z=A(K)
 330 LET A(K)=A(R-K+1)
 340 LET A(R-K+1)=Z
 350 NEXT K
 360 GO SUB 600
 400 FOR K=1 TO N
 410 IF NOT A(K)=K THEN GO TO 220
 420 NEXT K
 500 PRINT
 505 PRINT
 510 PRINT "YOU WON IN ";T;" MOVES"
 520 PRINT
 530 PRINT "TRY AGAIN? (Y OR N)"
 540 INPUT A$
 550 IF A$="Y" THEN GO TO 50
 555 PRINT
 560 PRINT
 565 PRINT
 568 PRINT
 570 PRINT ,"OK HOPE YOU HAD FUN"
 580 STOP
 600 CLS
 605 PRINT
 610 PRINT ,"REVERSE"
 620 PRINT
 630 PRINT
 640 PRINT "YOUR LIST IS NOW:"
 650 PRINT
 660 PRINT
 670 FOR K=1 TO N
 680 PRINT " ";A(K);
 690 NEXT K
 700 PRINT
 705 PRINT
 710 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.