4H‰ ƒ„>F >ÿÿÿÿ~ déñ¹däÉd» n·:’1610:’1680 x ŒN(3),P(10),Q(10),R(10),K(100) ‚)C=1:A=2:D=3:H=0:P(0)=99:Q(0)=99:R(0)=99 ŒE=0:J=0:I=0:G=0:B=0:· –#–"HOW MANY DISCS WOULD YOU LIKE"H  0„H>10‰ƒ"TOO MANY-MAXIMUM IS 10-TRY AGAIN":150 ª*„H<=0‰ƒ"SORRY, THAT'S NOT POSSIBLE":150 ´ „H>3‰210 ¾)ƒ"YOU HAVE NO SENSE OF ADVENTURE - BUT" È+ƒ"I SUPPOSE YOU HAVE TO START SOMEWHERE"\ ÒN(1)=H:N(2)=0:N(3)=0 ܃"TYPE 'A' IF YOU WANT" æ5ƒ"ME TO DO ALL THE WORK (I.E. AUTOMATIC OPERATION)" ð,ƒ"OTHERWISE TYPE 'M' FOR MANUAL OPERATION" úƒ"WHICH WOULD YOU LIKE "; $–"AUTOMATIC OR MANUAL (A OR M)"M1$ „ M1$="A"´M1$="a"‰280ˆ410 S=0 ",–"HOW FAST (0 IS FASTEST, 10 IS SLOWEST)"S , ·:’1370 6 ’750:G=4 @#K(G-3)=H:K(G-2)=C:K(G-1)=D:K(G)=A J B=G:G=G+4 T5K(G-3)=K(B-3):K(G-2)=K(B-2):K(G-1)=K(B-1):K(G)=K(B) ^ „H<>1‰380 hG=G+2:K(G-1)=1:K(G)=3:’800 r390 |’1030 †±(832):ƒ"";:720 ¡ Manual operation š ·:’1370:S=0 ¤’750 ®3±(832):ƒ" "; ¸±(832):–"FROM PEG"F „F<1´F>3‰ƒ"NO SUCH PEG":430 Ì+±(896):ƒ" " Ö±(860):–"TO PEG"T à2±(896):ƒ" ":±(896) ê „T<1´T>3‰ƒ"NO SUCH PEG":430 ô„F=T‰ƒ"NOT ALLOWED";:430 þ/„N(F)<=0‰ƒ"THERE ARE NO DISCS ON PEG ";F:430 I=N(F):J=N(T) F540,580,610 U=P(I) &„T=2‰V=Q(J):630 0V=R(J) :630 DU=Q(I):„T=1‰V=P(J):630 NV=R(J) X630 bU=R(I):„T=2‰V=Q(J):630 lV=P(J) v„U>V‰ƒ"NOT ALLOWED":430 €G=G+2:K(G-1)=F:K(G)=T Š’800 ” „N(1)=0³N(2)=0³N(3)=H‰670ˆ430 žM2=2^Í(H)-1:M=¼(M2) ¨3±(832):ƒ" " ² ±(832):ƒ""; ¼%„E=M‰ƒ"CONGRATULATIONS! YOU DID IT" Æ1ƒ"YOU TRANSFERRED ALL THE DISCS IN ";E;" MOVES" Ð)–"CARE FOR ANOTHER GAME (YES OR NO)"A1$ Ú„A1$="yes"´A1$="YES"‰140 ä·:‘ îJ=H øŠI=1™H P(I)=J:J=J-1:‹I  • ¡ Shift disc calculations  E=E+1:L=K(G-1):O=K(G) *ŠI=1™3+(30*S):‹I 4I=N(L):Y=10+(I*2) > „L<>1‰850 HW=P(I):X=20:880 R „L<>2‰870 \W=Q(I):X=52:880 f W=R(I):X=84 p P1=2:Z=W z’1520 „I=N(O)+1:Y=10+(I*2) Ž „O<>1‰930 ˜P(I)=W:X=20:960 ¢ „O<>2‰950 ¬Q(I)=W:X=52:960 ¶ R(I)=W:X=84 ÀP1=1 Ê’1520 Ô N(L)=N(L)-1 Þ N(O)=N(O)+1 èG=G-2 ò±(23):ƒ"MOVE ";E ü• ¡ Recursive procedures „K(G-3)>2‰1050ˆ1220  B=G:G=G+4 $K(G-3)=K(B-3)-1 .K(G-2)=K(B-2) 8 K(G-1)=K(B) B K(G)=K(B-1) L’1030 V B=G:G=G+2 `K(G-1)=K(B-2) j K(G)=K(B-1) t’800 ~ B=G:G=G+4 ˆK(G-3)=K(B-3)-1 ’ K(G-2)=K(B) œK(G-1)=K(B-1) ¦ K(G)=K(B-2) °’1030 º1340 Ä B=G:G=G+2 ÎK(G-1)=K(B-2) Ø K(G)=K(B) â’800 ì B=G:G=G+2 öK(G-1)=K(B-2)  K(G)=K(B-1)  ’800  B=G:G=G+2  K(G-1)=K(B) ( K(G)=K(B-1) 2’800 <G=G-4 F• P ¡ Draw pegs Z· d»:ŠI=1™102:§(I,10):‹I n ŠI=10™32 x§21,I:§53,I:§85,I ‚‹I Œ7±(576):ƒ" 1 2 3" – Y=12:X=20   ŠI=H™1š-1 ªŠJ=1™I ´§X-J,Y:§X+J+2,Y ¾‹J ÈY=Y+2 Ò‹I Ü• æ¡ Switch procedure ð „P1=2‰1570 úŠJ=1™Z §X-J,Y:§X+J+2,Y ‹J 1600 "ŠJ=1™Z ,¨X-J,Y:¨X+J+2,Y 6‹J @• J±(256):ƒ[A63 42] T ƒ[A63 42]\ ^±(463):ƒ"T H E T O W E R S" h±(542):ƒ"O F H A N O I"\ r ƒ[A63 42] | ƒ[A63 42] †• ¡ š±(896) ¤,–"DO YOU WANT INSTRUCTIONS (YES OR NO)"A1$ ®„A1$="yes"´A1$="YES"‰1720ˆ• ¸· ±(23):«:ƒ"INSTRUCTIONS"\:ª Ì7ƒ"THERE ARE THREE PEGS. ON ONE OF THESE ARE ARRANGED" Ö5ƒ"IN ORDER OF DECREASING SIZE, A NUMBER OF DISCS."\ à3ƒ"THE OBJECT IS TO MOVE ALL THE DISCS FROM PEG 1" ê6ƒ"TO PEG 3, SUBJECT TO THE FOLLOWING CONSTRAINTS:-"\ ô0ƒ" 1. ONLY ONE DISC MAY BE MOVED AT A TIME" þ5ƒ" 2. A DISC MAY NOT BE PLACED ON TOP OF A DISC" ƒ" WHICH IS SMALLER" ’2130 ±(23):«:ƒ"PLAYING HANOI"\:ª &7ƒ"THERE ARE TWO MODES OF PLAY. THESE ARE (A)UTOMATIC" 07ƒ"AND (M)ANUAL AND YOU WILL BE ASKED TO SELECT ONE."\ :«:ƒ"AUTOMATIC OPERATION":ª D<ƒ"THE COMPUTER WILL ASK YOU HOW MANY DISCS YOU WOULD LIKE" N:ƒ"MOVED AND HOW FAST YOU WOULD LIKE THEM MOVED. IT WILL" X;ƒ"THEN PROCEED TO TRANSFER THE DISCS FROM PEG 1 TO PEG 3" b$ƒ"USING PEG 2 AS AN INTERMEDIATE." l’2130 v±(23):«:ƒ"PLAYING HANOI"\:ª €«:ƒ"MANUAL OPERATION":ª Š9ƒ"HERE YOU WILL BE ASKED HOW MANY DISCS YOU WOULD LIKE" ”=ƒ"TO MOVE. YOU WILL THEN BE PROMPTED TO TYPE THE NUMBER OF" ž>ƒ"THE PEG THE DISC IS TO BE TAKEN OFF AND THE NUMBER OF THE" ¨@ƒ"PEG THE DISC IS TO BE PLACED ON. WHEN YOU HAVE SUCCESSFULLY" ²:ƒ"TRANSFERRED ALL DISCS YOU WILL BE TOLD HOW MANY MOVES" ¼ ƒ"IT TOOK." Æ’2130 б(23):«:ƒ"SUGGESTION"\:ª Ú:ƒ"IF YOU ARE UNSURE OF THE GAME TRY AUTOMATIC OPERATION" ä;ƒ"WITH ABOUT FOUR DISCS AND LOW SPEED (E.G.10). THEN SIT" î?ƒ"BACK AND LET THE COMPUTER DO ALL THE WORK - AFTER ALL THAT" øƒ"IS WHAT IT IS THERE FOR!"\ ;ƒ"FOR A GIVEN NUMBER OF DISCS, N, THE SMALLEST NUMBER OF"  "ƒ"MOVES REQUIRED IS GIVEN BY :-" ƒ" M=2^N-1"  :ƒ"SO FOR 3 DISCS THAT'S 7 MOVES, 4 DISCS 15 MOVES UP TO" *7ƒ"THE MAXIMUM OF 10 DISCS WHICH REQUIRE 1023 MOVES."\ 4ƒ" HAVE FUN!!!!" >’2130 H• R&±(960):ƒ"PRESS 'RETURN' WHEN READY"; \–A1$ f· p• ÿÿHANOI€(ÍR’ÍM‡ÍH†Äé¡Í?˜ÃÁƒÍš2àÍæšÃÁƒÍŽ„* %"Ü6ÿ*Ò#"ØÃ