home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1991 August / 1991-08.d64 / riddle (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1991-01-01  |  7.8 KB  |  267 lines

  1. 1 rem copyright 1991 - compute publications intl ltd - all rights reserved
  2. 10 dima$(99),g$(99),q(99),c(99),n(99),o(99),d$(99),ds(99),q$(99)
  3. 20 gosub 1940:gosub2560
  4. 30 pa$="":zr$="":print"[147]"chr$(158);:poke53272,23:printchr$(8)
  5. 40 gosub1960
  6. 50 getp$:ifp$=""then50
  7. 60 h=val(p$):if h<1 or h>9 then 50
  8. 70 on h goto 1420,110,110,1250,700,2160,2170,1540,1830
  9. 80 goto20
  10. 90 goto2130
  11. 100 if p$="y"then30
  12. 110 gosub1560:ifrq$<>""thenprint"[195][213][210][210][197][206][212][160][209][213][197][211][212][201][207][206]":print""rq$"[146]"
  13. 120 print"[197][206][212][197][210][160][210][201][196][196][204][197][160][209][213][197][211][212][201][207][206]":gosub1650
  14. 130 ifip$<>""andp$<>"_"thenrq$=ip$
  15. 140 if p$="_"then30
  16. 150 if rq$=""then110
  17. 160 gosub1560:print"[195][213][210][210][197][206][212][160][209][213][197][211][212][201][207][206]":print""rq$"[146]":print
  18. 170 if ra$<>""thenprint"[195][213][210][210][197][206][212][160][193][206][211][215][197][210]":print""ra$"[146]"
  19. 180 print"[197][206][212][197][210][160][210][201][196][196][204][197][160][193][206][211][215][197][210]":gosub1650
  20. 190 if ip$<>"" and p$<>"_" then ra$=ip$:lr=len(ra$)
  21. 200 if p$="_" then 110
  22. 210 if ra$="" then 160
  23. 220 fori=1tolr:ifasc(mid$(ra$,i,1))=32thenprint"[206][207][160][211][208][193][195][197][211]"
  24. 230 ifasc(mid$(ra$,i,1))=32thenprint:goto180
  25. 240 a=asc(mid$(ra$,i,1))
  26. 250 ifa>90 or a<64 thenprint"[204][207][215][197][210][195][193][211][197][160][204][197][212][212][197][210][211][160][207][206][204][217]":print:goto180
  27. 260 nexti
  28. 270 gosub1560:ifi$<>""thenprint"[195][213][210][210][197][206][212][160][201][206][211][212][210][213][195][212][201][207][206][211]":print""i$"[146]":print
  29. 280 print"[197][206][212][197][210][160][201][206][211][212][210][213][195][212][201][207][206][211]":gosub1650
  30. 290 ifip$<>"" and p$<>"_" then i$=ip$
  31. 300 if p$="_" then 160
  32. 310 if i$="" then 270
  33. 320 lr = len(ra$)
  34. 330 gosub1560:printlr;" [196][201][211][212][210][193][195][212][207][210][211]":print
  35. 340 if n<>0 then print"[195][213][210][210][197][206][212][160][206][213][205][194][197][210][160][207][198][160][208][210][207][194][204][197][205][211]":print""n"[146]":print
  36. 350 print"[197][206][212][197][210][160][206][213][205][194][197][210][160][207][198][160][208][210][207][194][204][197][205][211] ":gosub1650
  37. 360 if ip$<>""andp$<>"_"thenn=val(ip$)
  38. 370 if p$="_"then 270
  39. 380 if n = 0 then 330
  40. 390 i=1
  41. 400 gosub1560:printn;" [209][213][197][211][212][201][207][206][211]":print
  42. 410 if q$(i)<>""thenprint"[195][213][210][210][197][206][212][160][209][213][197][211][212][201][207][206]"i:print""q$(i)"[146]":print
  43. 420 print"[197][206][212][197][210][160][209][213][197][211][212][201][207][206] ";i:gosub1650
  44. 430 ifip$<>""andp$<>"_"thenq$(i)=ip$
  45. 440 if len(q$(i))>70 thenprint"[206][207][160][205][207][210][197][160][212][200][193][206] 70[160][195][200][193][210][193][195][212][197][210][211]"
  46. 450 if len(q$(i))>70 thenprint:goto420
  47. 460 if p$="_"then if i=1 then 330
  48. 470 if p$="_"then if i>1 then i=i-1:goto400
  49. 480 if a$(i)<>""thenprint"[195][213][210][210][197][206][212][160][210][201][199][200][212][160][193][206][211][215][197][210]":print""a$(i)"[146]"
  50. 490 print:print"[197][206][212][197][210][160][210][201][199][200][212][160][193][206][211][215][197][210]":gosub1650
  51. 500 ifip$<>""andp$<>"_"then a$(i)=ip$
  52. 510 if p$="_" then 400
  53. 520 if a$(i)=""then480
  54. 530 if len(a$(i))>70 then print:print"[206][207][160][205][207][210][197][160][212][200][193][206] 70 [195][200][193][210][193][195][212][197][210][211]"
  55. 540 if len(a$(i))>70 then print:goto420
  56. 550 i=i+1:if i<=n then 400
  57. 560 i=1
  58. 570 gosub1560:printlen(ra$);" [196][201][211][212][210][193][195][212][207][210][211]":print
  59. 580 ifd$(i)<>""thenprint"[195][213][210][210][197][206][212][160][196][201][211][212][210][193][195][212][207][210]";i:print""d$(i)"[146]":print
  60. 590 print"[197][206][212][197][210] [196][201][211][212][210][193][195][212][207][210]";i:gosub1650
  61. 600 ifip$<>""andp$<>"_"thend$(i)=ip$
  62. 610 if len(d$(i))>70 then print"[206][207][160][205][207][210][197][160][212][200][193][206][160]70[160][195][200][193][210][193][195][212][197][210][211]":print:goto590
  63. 620 if p$="_" then i=i-1:ifi>0 then goto570
  64. 630 ifi<=0 then i=n:goto400
  65. 640 if d$(i)=""then570
  66. 650 forj=1ton:a=val(a$(j)):ifd$(i)=a$(j) then670
  67. 660 nextj:goto680
  68. 670 print"[196][213][208][204][201][195][193][212][197][211] [193][206][160][193][206][211][215][197][210]":print:goto590
  69. 680 i=i+1:ifi<=len(ra$) then 570
  70. 690 goto30
  71. 700 gosub1580:input"[200][201][212][160][210][197][212][213][210][206][160][215][200][197][206][160][208][210][201][206][212][197][210][160][201][211][160][210][197][193][196][217]";zr$
  72. 705 ifzr$="_"orra$=""then30
  73. 710 gosub 1580
  74. 720 input"[206][213][205][194][197][210][160][207][198][160][195][207][208][201][197][211]";n$:nc=val(n$):ifn$="" or n$="_" then 30
  75. 730 open1,4,7:forpg=1tonc
  76. 740 forrs=139to143:pokers,asc(ra$):nextrs:gosub1390
  77. 750 x=0:fori=1ton:ifx<len(q$(i))thenx=len(q$(i))
  78. 760 nexti
  79. 770 it=x+9:cn=int(80/it):qc=cn
  80. 780 lq=0:zs=1:ze=76:ll=len(rq$):ifze>=llthenze=ll:goto820
  81. 790 ifmid$(rq$,ze,1)<>" "andze<>1thenze=ze-1:goto790
  82. 800 print#1,mid$(rq$,zs,ze-zs+1):zs=ze+1:ze=ze+76:lq=lq+1
  83. 805 ifze>=llthenze=ll:goto 820
  84. 810 goto790
  85. 820 n5=12+lq+li
  86. 830 print#1,right$(rq$,ll-zs+1):print#1:lq=lq+1
  87. 840 zs=1:ze=76:li=0:ll=len(i$):ifze>=llthenze=11:goto880
  88. 850 ifmid$(i$,ze,1)<>" "andze<>1thenze=ze-1:goto850
  89. 860 print#1,mid$(i$,zs,ze-zs+1):zs=ze+1:ze=ze+76
  90. 865 ifze>=llthenze=ll:li=li+1:goto880
  91. 870 goto850
  92. 880 print#1,right$(i$,ll-zs+1):li=li+1
  93. 890 t=cn:print#1:print#1:fori=1ton
  94. 900 print#1,str$(i);". ";q$(i);spc(it-len(q$(i))-len(str$(i))-2);
  95. 910 t=t-1:ift<=0thent=cn:print#1:print#1:n5=n5+2:gosub2130
  96. 920 nexti:print#1
  97. 930 fori=1ton
  98. 940 j=int(1+n*rnd(1)):ifc(j)=1then940
  99. 950 c(j)=1:o(i)=j:nexti:fori=1ton:c(i)=0:nexti
  100. 960 x=0:fori=1ton:ifx<len(a$(i))thenx=len(a$(i))
  101. 970 nexti
  102. 980 nd=len(ra$):fori=1tond
  103. 990 fori=1tond:ifx<len(d$(i))thenx=len(d$(i))
  104. 1000 :nexti:it=x+6:cn=int(80/it):fori=1tond
  105. 1010 j=int(1+nd*rnd(1)):ifc(j)=1then1010
  106. 1020 ds(i)=j:c(j)=1:nexti:fori=1tond:c(i)=0:nexti
  107. 1030 fori=1tolen(ra$):ifx<len(d$(i))thenx=len(d$(i)):nexti
  108. 1040 ifpa$="a"thenprint#1:print#1,ra$:print#1:i=1:j=1:t=cn
  109. 1050 ifpa$<>"a"thenprint#1:print#1:print#1:i=1:j=1:t=cn
  110. 1060 fq=len(ra$)/(n+len(ra$))
  111. 1070 k=rnd(1)
  112. 1080 ifk>fq thenm=int(1+26*rnd(1))
  113. 1090 lo=len(str$(o(i)))-3:ro=lo+2:z=o(i):z$=right$(str$(z),ro)
  114. 1095 ifpa$<>"a"then1130
  115. 1100 ifk>fq andi<=n and pa$="a" thenprint#1,z$;chr$(64+m);"=";a$(z);
  116. 1110 ifk>fq andi<=n thenprint#1,spc(it-(len(chr$(64+m))+3+len(a$(o(i))))-lo);
  117. 1120 ifk>fq andi<=n and pa$="a" then goto 1150
  118. 1130 ifk>fq andi<=n thenprint#1,chr$(64+m);" = ";a$(o(i));
  119. 1140 ifk>fq andi<=n thenprint#1,spc(it-(len(chr$(64+m))+3+len(a$(o(i)))));
  120. 1150 ifk>fq andi<=n theni=i+1:t=t-1
  121. 1160 ift<=0thent=cn:print#1:print#1:n5=n5+2:gosub2130
  122. 1170 if k>fq then1220
  123. 1180 ifj<=len(ra$)thenprint#1,mid$(ra$,j,1);" = ";d$(ds(j));
  124. 1190 ifj<=len(ra$)thenprint#1,spc(it-4-len(d$(ds(j))));
  125. 1200 c=0
  126. 1210 ifj>len(ra$)then1220
  127. 1215 j=j+1:t=t-1:ift<=0 thent=cn:print#1:print#1:n5=n5+2:gosub90
  128. 1220 ifi>n and j>len(ra$)then gosub1600
  129. 1230 ifi>n and j>len(ra$)then nextpg:close1:goto30
  130. 1240 goto1070
  131. 1250 gosub1580:n$="":input"filename";n$:ifn$="_" or n$="" or ra$="" then 30
  132. 1260 n$=n$+",s,w":open5,8,5,n$:nd=len(ra$)
  133. 1270 open15,8,15:input#15,e,e$,c,d
  134. 1280 if e<>63 then goto1310
  135. 1290 printe$;",ok to overwrite (y/n)";:inputyn$
  136. 1300 if left$(yn$,1)<>"y" then close5:close15:goto30
  137. 1310 close5:print#15,"s0:"+n$:close15:open5,8,5,n$
  138. 1320 print#5,rq$:print#5,ra$:print#5,n:fori=1ton:print#5,q$(i):nexti
  139. 1330 fori=1ton:print#5,a$(i):nexti
  140. 1340 fori=1tond:print#5,d$(i):nexti:print#5,i$:printchr$(147);
  141. 1350 close5:i=n+1:j=len(ra$)+1:c=0:goto30
  142. 1360 ifc=3 thenrun
  143. 1370 ifc=4 thenclose1:printchr$(147);:end
  144. 1380 goto1070
  145. 1390 print#1,"[195]ross out the letters that go with the right answers."
  146. 1400 print#1,"[212]he letters left will spell the answer to the following."
  147. 1410 print#1:print#1:return
  148. 1420 gosub1580:n$="":input"[198]ilename";n$:ifn$="_"orn$=""then30
  149. 1430 n$="0:"+n$+",s,r":open5,8,5,n$
  150. 1440 open15,8,15:input#15,e,e$,c,d
  151. 1450 if e<>62 then goto1470
  152. 1460 printe$;",hit <[210][197][212][213][210][206]>";:inputyn$:close5:close15:goto30
  153. 1470 close5:close15:open5,8,5,n$
  154. 1480 gosub2100:rq$=zz$:gosub2100:ra$=zz$:gosub2100:n=val(zz$):fori=1ton
  155. 1490 gosub2100
  156. 1500 q$(i)=zz$:nexti
  157. 1510 fori=1ton:gosub2100:a$(i)=zz$:nexti:fori=1tolen(ra$):gosub2100:d$(i)=zz$
  158. 1520 nexti
  159. 1530 gosub2100:i$=zz$:close5:goto30
  160. 1540 run
  161. 1550 qq$="[197][206][212][197][210][160][206][213][205][194][197][210][160][207][198][160][208][210][207][194][204][197][205][211]":return
  162. 1560 print"[147]           [200][201][212][160]_[160][212][207][160][199][207][160][194][193][195][203]   [160][160][160][160][160][160][160][160][160][160][146]"
  163. 1570 return
  164. 1580 print"[147]          [197][206][212][197][210][160]_[160][212][207][160][199][207][160][194][193][195][203]   [160][160][160][160][160][160][160][160][160][146]"
  165. 1590 return
  166. 1600 nl=12+lq+li+2*int(n/qc)
  167. 1610 n2=nl
  168. 1620 nl=nl+2*(int((len(ra$)+n)/cn))
  169. 1630 ifnl>63thennl=nl-63:goto1630
  170. 1640 fori=nlto66:print#1:nexti:return
  171. 1650 ip$=""
  172. 1660 print" [146][157] [157] [146][157] [157]";
  173. 1670 iflen(ip$)>254then goto 1790
  174. 1680 getp$:ifp$=""then1660
  175. 1690 ifasc(p$)=19orasc(p$)=147thengoto1660
  176. 1700 ifp$="_"thenreturn
  177. 1710 if p$="" or p$="[145]" or p$="" or p$="[157]" then 1660
  178. 1720 printp$;" [146][157] [157]";
  179. 1730 ifasc(p$)<>20andasc(p$)<>130andasc(p$)<>13thenip$=ip$+p$:goto1660
  180. 1740 ifasc(p$)=13thenreturn
  181. 1750 if len(ip$)<1 and (asc(p$)=20orasc(p$)=157)thenprint"";:goto1650
  182. 1760 if len(ip$)=1 and (asc(p$)=20orasc(p$)=157)thengoto1650
  183. 1770 ifasc(p$)=20orasc(p$)=157thenip$=left$(ip$,len(ip$)-1):goto1660
  184. 1780 goto1660
  185. 1790 print:print"[206][207][160][205][207][210][197][160][212][200][193][206][160]254 [195][200][193][210][193][195][212][197][210][211]":print
  186. 1800 goto 1650
  187. 1810 getp$:ifp$<>""then1810
  188. 1820 goto 1660
  189. 1830 sys770
  190. 1840 rem print questions
  191. 1850 x=0:fori=1ton:ifx<len(q$(i))thenx=len(q$(i))
  192. 1860 nexti
  193. 1870 it=x+9:cn=int(80/it):qc=cn
  194. 1880 n5=14+int(len(rq$)/80)+int(len(i$)/80)+2*int(n/qc)
  195. 1890 nl=8+int(len(rq$)/80)+int(len(i$)/80)+2*int(n/qc)
  196. 1900 print#1:print#1,rq$:print#1:t=cn:print#1,i$:print#1:print#1:fori=1ton
  197. 1910 print#1,i;". ";q$(i);spc(it-len(q$(i))-len(str$(i))-3);
  198. 1920 t=t-1:ift<=0thent=cn:print#1:print#1
  199. 1930 nexti:print#1:return
  200. 1940 poke40503,128:poke40504,128:poke53280,6:poke53281,0:poke646,1
  201. 1950 fori=1to15:closei:next:return
  202. 1960 print"[147]"tab(8)"      [210][201][196][196][204][197][160][205][197][206][213]       [146]"
  203. 1970 printtab(8)xs$tab(32)xs$
  204. 1980 printtab(8)xs$tab(10)"1 = [199][197][212][160][198][210][207][205][160][196][201][211][203]"tab(32)xs$
  205. 1990 printtab(8)xs$tab(10)"2 = [195][210][197][193][212][197][160][206][197][215][160][210][201][196][196][204][197]"tab(32)xs$
  206. 2000 printtab(8)xs$tab(10)"3 = [195][207][210][210][197][195][212]"tab(32)xs$
  207. 2010 printtab(8)xs$tab(10)"4 = [211][193][214][197][160][212][207][160][196][201][211][203]"tab(32)xs$
  208. 2020 printtab(8)xs$tab(10)"5 = [208][210][201][206][212]"tab(32)xs$
  209. 2030 printtab(8)xs$tab(10)"6 = [208][210][201][206][212][160][193][206][211][215][197][210][211]"tab(32)xs$
  210. 2040 printtab(8)xs$tab(10)"7 = [196][201][211][203][160][196][201][210][197][195][212][207][210][217]"tab(32)xs$
  211. 2050 printtab(8)xs$tab(10)"8 = [195][204][197][193][210][160][205][197][205][207][210][217]"tab(32)xs$
  212. 2060 printtab(8)xs$tab(10)"9 = [209][213][201][212]"tab(32)xs$
  213. 2070 printtab(8)xs$tab(32)xs$
  214. 2080 printtab(8)"       [200][201][212][160][195][200][207][201][195][197][160]       [146]"
  215. 2090 return
  216. 2100 zz$=""
  217. 2110 get#5,z$:ifasc(z$)<>13thenzz$=zz$+z$:goto2110
  218. 2120 return
  219. 2130 if n5>63 then print#1:print#1:print#1
  220. 2140 if n5>63 then n5=n5-63:return
  221. 2150 return
  222. 2160 pa$="a":h=5:goto70
  223. 2170 c=1
  224. 2180 s$=" ":forbl=0to18:s$=s$+" ":next
  225. 2190 open8,8,0,"$"
  226. 2200 print"[147]";
  227. 2210 get#8,b$:ifb$<>chr$(34)then2210
  228. 2220 printspc(8)"";"";b$;
  229. 2230 get#8,b$:ifb$<>""thenprintb$;:goto2230
  230. 2240 print
  231. 2250 for e=0 to 19
  232. 2260 get#8,b$,b$:get#8,h$,l$
  233. 2270 get#8,b$:ifb$<>" "then2490
  234. 2280 get#8,b$:ifb$<>chr$(34) then 2280
  235. 2290 if c/2=int(c/2) then printtab(19)" ";
  236. 2300 forxl=1to16:get#8,b$
  237. 2310 ifb$="" or b$=chr$(34) then b$=" "
  238. 2320 print ""b$;:next
  239. 2330 get#8,b$
  240. 2340 get#8,b$:ifb$=" "then2340
  241. 2350 print",";b$;" "
  242. 2360 get#8,b$:ifb$<>""then2360
  243. 2370 next:c=c+1
  244. 2380 if c=2 then print chr$(19)+"";:goto2250
  245. 2390 print""chr$(158)"      [211][208][193][195][197][146] = [205][207][210][197][160]";
  246. 2400 print"    [205][146] = [205][197][206][213]";
  247. 2410 getj$:ifj$=""then2410
  248. 2420 ifj$<>" "andj$<>"m"then2410
  249. 2430 print"                                     ";
  250. 2440 ifj$="m"thenclose8:goto30
  251. 2450 print""+"";
  252. 2460 if c/2<>int(c/2)thenforxl=0to19:prints$:next:goto2480
  253. 2470 forxl=0to19:printtab(19);s$:next
  254. 2480 print""; s$;s$;"";"";:goto2250
  255. 2490 xl=asc(h$+chr$(0)):xl$=str$(xl+256*asc(xb$+chr$(0)))
  256. 2500 poke214,23:poke211,10:print chr$(145);"[156]";xl$;" blocks free ":close8:xc=1
  257. 2510 print "            ";chr$(158);"[200][201][212] [211][208][193][195][197] [194][193][210]";
  258. 2520 geta$:ifa$=""then2520
  259. 2530 ifa$<>" "then2520
  260. 2540 printchr$(5)+chr$(147):goto30
  261. 2550 data 128,112,207,250,195
  262. 2560 restore:forri=139to143:readrn:pokeri,rn:next:poke649,1:xs$=" [146]"
  263. 2570 bs$="[147]"
  264. 2580 bl$="                                        "
  265. 2590 hn$="_ [212][207][160][199][207][160][194][193][195][203][146]"
  266. 2600 return
  267.