Source Code

>LIST
100 PRINT "R E V E R S E": PRINT

110 DIM A(9), B(9)
115 T=0
120 FOR I=1 TO 9: A(I)=0 : NEXT
I
130 FOR I= 1 TO 9
140 J= RND (20) +1
150 IF J>9 THEN 140
160 IF A(J)#0 THEN 140
170 A(J) =I
180 NEXT I
190 PRINT " 1 2 3 4 5 6 7 8 9"
: PRINT " -----------------"
191 PRINT "("):: FOR I=1 TO 9: PRINT
A(I):: IF I<9 THEN PRINT " "
:: NEXT I
192 PRINT ")": PRINT"------------
------"
193 PRINT
200 INPUT "HOW MANY SHALL I REVERSE
",N
210 IF N<=9 THEN 230
220 PRINT "OOPS! TOO MANY- I CAN REV
ERSE AT MOST 9": GOTO 200
230 IF N>1 THEN 250
240 PRINT "OOPS ! TOO SMALL; YOU MUS
T REVERSE SOMETHING!"
241 GOTO 200
250 T=T+1
260 FOR I=1 TO 9: B(I)=A(I): NEXT
I
270 FOR I=1 TO N:J=N+1-I: A(J)=
B(I): NEXT I
280 I=0
290 I=I+1
300 IF A(I) > A(I+1) THEN 190
310 IF I < 8 THEN 290
320 PRINT "YOU WON IN ";T;" MOVES"
330 END

R E V E R S E

1 2 3 4 5 6 7 8 9
-----------------
(4 3 9 5 8 6 2 7 1)
-----------------
HOW MANY SHALL I REVERSE?3
1 2 3 4 5 6 7 8 9
-----------------
(9 3 4 5 8 6 2 7 1)
-----------------
HOW MANY SHALL I REVERSE?9

1 2 3 4 5 6 7 8 9
-----------------
(1 7 2 6 8 5 4 3 9)
-----------------

HOW MANY SHALL I REVERSE?1

OOPS! TOO SMALL: YOU MUST REVERSE SOMETHI
NG!
HOW MANY SHALL I REVERSE?2

1 2 3 4 5 6 7 8 9
-----------------
(7 1 2 6 8 5 4 3 9)
-----------------

HOW MANY SHALL I REVERSE?4
1 2 3 4 5 6 7 8 9
-----------------
(6 2 1 7 8 5 4 3 9)
-----------------

HOW MANY SHALL I REVERSE?3

1 2 3 4 5 6 7 8 9
-----------------
(1 2 6 7 8 5 4 3 9)
-----------------
HOW MANY SHALL I REVERSE?5
1 2 3 4 5 6 7 8 9
-----------------
(8 7 6 2 1 5 4 3 9)
-----------------
HOW MANY SHALL I REVERSE?8
1 2 3 4 5 6 7 8 9
-----------------
(3 4 5 1 2 6 7 8 9)
-----------------
HOW MANY SHALL I REVERSE?3
1 2 3 4 5 6 7 8 9
-----------------
(5 4 3 1 2 6 7 8 9)
-----------------
HOW MANY SHALL I REVERSE?5

1 2 3 4 5 6 7 8 9
-----------------
(2 1 3 4 5 6 7 8 9)
-----------------

HOW MANY SHALL I REVERSE?2

YOU WON IN 10 MOVES