mirror of
https://github.com/jscrane/Apple1.git
synced 2024-11-22 21:33:01 +00:00
31 lines
838 B
Plaintext
31 lines
838 B
Plaintext
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 REVERSE AT MOST 9": GOTO 200
|
|
230 IF N>1 THEN 250
|
|
240 PRINT "OOPS ! TOO SMALL; YOU MUST 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
|
|
|