10 PRINT TAB(32);"REVERSE"
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT
100 PRINT "REVERSE -- A GAME OF SKILL": PRINT
140 REM *** N=NUMBER OF NUMBERS
150 N=9
160 INPUT "DO YOU WANT THE RULES (1=Y, 0=N): ";A
180 IF A=0 THEN 210
190 GOSUB 710
200 REM *** MAKE A RANDOM LIST A(1) TO A(N)
210 @(1)=RND(N-1)+2
220 FOR K=2 TO N
230 @(K)=RND(N)+1
240 FOR J=1 TO K-1
250 IF @(K)=@(J) THEN UNLOOP : GOTO 230
260 NEXT J:NEXT K
280 REM *** PRINT ORIGINAL LIST AND START GAME
290 PRINT: PRINT "HERE WE GO ... THE LIST IS:"
310 T=0
320 GOSUB 610
330 PRINT "HOW MANY SHALL I REVERSE";
340 INPUT R
350 IF R=0 THEN 520
360 IF (R>N)=0 THEN 390
370 PRINT "OOPS! TOO MANY! I CAN REVERSE AT MOST ";N:GOTO 330
390 T=T+1
400 REM *** REVERSE R NUMBERS AND PRINT NEW LIST
410 FOR K=1 TO R/2
420 Z=@(K)
430 @(K)=@(R-K+1)
440 @(R-K+1)=Z
450 NEXT K
460 GOSUB 610
470 REM *** CHECK FOR A WIN
480 FOR K=1 TO N
490 IF @(K)#K THEN UNLOOP : GOTO 330
500 NEXT K
510 PRINT "YOU WON IT IN ";T;" MOVES!!!":PRINT
520 PRINT
530 INPUT "TRY AGAIN (1=Y 0=NO): ";A
550 IF A=1 THEN 210
560 PRINT: PRINT "O.K. HOPE YOU HAD FUN!!":GOTO 999
600 REM *** SUBROUTINE TO PRINT LIST
610 PRINT:FOR K=1 TO N:PRINT @(K);" ";:NEXT K
650 PRINT:PRINT:RETURN
700 REM *** SUBROUTINE TO PRINT THE RULES
710 PRINT:PRINT "THIS IS THE GAME OF 'REVERSE'.  TO WIN, ALL YOU HAVE"
720 PRINT "TO DO IS ARRANGE A LIST OF NUMBERS (1 THROUGH ";N;")"
730 PRINT "IN NUMERICAL ORDER FROM LEFT TO RIGHT.  TO MOVE, YOU"
740 PRINT "TELL ME HOW MANY NUMBERS (COUNTING FROM THE LEFT) TO"
750 PRINT "REVERSE.  FOR EXAMPLE, IF THE CURRENT LIST IS:"
760 PRINT:PRINT "2 3 4 5 1 6 7 8 9"
770 PRINT:PRINT "AND YOU REVERSE 4, THE RESULT WILL BE:"
780 PRINT:PRINT "5 4 3 2 1 6 7 8 9"
790 PRINT:PRINT "NOW IF YOU REVERSE 5, YOU WIN!"
800 PRINT:PRINT "1 2 3 4 5 6 7 8 9":PRINT
810 PRINT "NO DOUBT YOU WILL LIKE THIS GAME, BUT"
820 PRINT "IF YOU WANT TO QUIT, REVERSE 0 (ZERO).":PRINT: RETURN
999 END
