home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 73 / 073.d81 / alphametix (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  24KB  |  958 lines

  1. 10 rem alphametix
  2. 20 rem (c)ian adam 1990
  3. 40 ifathenrun50
  4. 48 gosub9000
  5. 50 gosub9100
  6. 100 gosub10000
  7. 110 gosub12900
  8. 120 onregosub20000,200,7000,8000,11000,9500
  9. 140 goto100
  10. 200 clr:gosub5000
  11. 210 ifefthen13000
  12. 220 gosub6000
  13. 230 ifefthen13000
  14. 250 gosub12700:ifre=1then350
  15. 260 ifre=2orre=3thengosub6290:goto250
  16. 265 ifre=6thenifpeek(828)thengosub16000:goto250
  17. 270 ifre=7thenrun50
  18. 275 ifre-4thenrun200
  19. 295 sys51200:tj=co:sj=10:pokepr+3,lr
  20. 300 fori=.to10:u(i)=.:l(i)=.:cl(i)=.:un$(i)="":next
  21. 310 aa=.:ef=.:cc=.:nc=.:ma=.:s=.:x$="[150]< [212]he end >
  22. 315 [153]"load":[141]14000
  23. 320 [129]i[178]1[164]r:d$[178]" "[170]rw$(i):[141]5800:[130]:[141]6020:[137]230
  24. 350 [141]6500
  25. 360 [139][194](pr[170]1)[178].[167] 700
  26. 400 [139][194](2)[167][141]2000
  27. 410 [139]ef[167]530
  28. 500 [141]2200
  29. 510 [139]re[178]7[167]600
  30. 520 [139]b[178]20[167][141]15000:[141]2400:[141]14500:[139]re[178]7[167]600
  31. 530 [158]51203:[141]6800
  32. 540 [137]360
  33. 600 [151]pr[170]1,.:m[178]1
  34. 610 x$[178]"def <(NULL)utput terminated>
  35. 620 print""x$
  36. 630 goto820
  37. 700 ifsthen800
  38. 730 print"[159]   [211]orry.. no solution to be found   [155]
  39. 740 [139][194](829)[167][141]11900
  40. 760 [137]840
  41. 800 [153]"open  no more solutions ... "
  42. 810 [139][194](829)[167][151]2,3:[141]7910
  43. 820 b[178]s[171]20[172][181]((s[171]1)[173]20)
  44. 830 [141]4300
  45. 840 [141]12300
  46. 850 [139]re[178]1[167][139]s[167][141]4000
  47. 860 [139]re[178]3[167]295
  48. 870 [139]re[178]4[167]920
  49. 880 [139]re[178]5[167][138]200
  50. 890 [139]re[178]7[167][138]50
  51. 900 [137]840
  52. 920 [151]832,[194](832)[176][194](829)
  53. 930 [151]829,1[171][194](829)
  54. 940 [141]6900:[137]840
  55. 1000 cs$(21)[178]"prime":cs$(22)[178]"not prime":cs$(23)[178]"square":cs$(24)[178]"not square
  56. 1010 cs$(26)="even":cs$(27)="odd":cs$(28)="1 or 2":cs$(29)="unknown
  57. 1020 [153]"load":[141]14000
  58. 1030 [153]""
  59. 1040 [129]i[178]1[164]r[171]1
  60. 1050 [153]i
  61. 1060 [130]
  62. 1070 [153]:[153]i
  63. 1080 [139]nc[179]9[167]1140
  64. 1100 [153]"open"[163]99)"valnough!
  65. 1110 printtab(59)"[159][208]ress a key.[155]
  66. 1120 [146]k,15:[161]a$:[142]
  67. 1140 [153]"open"[163]60)"right$f you have a clue
  68. 1150 print,,"for one letter,"tab(60)"press that letter.
  69. 1160 [153][163]60)"right$f the clue is for":[153],,"a line in the
  70. 1170 print,,"puzzle, press the"tab(60)"line #.
  71. 1180 [153][163]60)"(NULL)o more clues:  asc1list
  72. 1190 waitk,15:geta$
  73. 1200 a1$=chr$(asc(a$)+32):xx$="                   "
  74. 1210 ifval(a$)then1530
  75. 1220 ifa$="[133]"thenreturn
  76. 1240 fori=1tonm
  77. 1250 ifun$(i)=a1$then1280
  78. 1260 next
  79. 1270 printtab(60)"[150][212]hanks a lot![155]":gosub10200
  80. 1274 fori=1to1500:next:goto1020
  81. 1280 print"[159]",,"[208]ress a number for
  82. 1284 [153],,"the letter " a1$ ", or:
  83. 1286 print,,xx$
  84. 1288 print,,"a  if even   "
  85. 1290 print,,"b  if odd         "
  86. 1295 print,,"c  if it could be "
  87. 1296 print,,"   one or two     [155]
  88. 1298 [153],,xx$:[153],,xx$:[153],,xx$
  89. 1300 [146]k,15:[161]b$:[141]10200
  90. 1305 tj[178][198](b$)[171]48[170]7[172](b$[177]"9"):[139]tj[179].[176]tj[177]12[167]1270
  91. 1310 sj[178]so(i):[139]tj[179]10[167]1410
  92. 1320 [139]sj[179]10[167]1390
  93. 1330 [145]sj[171]9[137]1340,1350,1360,1480,1370,1480,1380
  94. 1340 [145]tj[171]9[137]1270,1510,1720
  95. 1350 [145]tj[171]9[137]1510,1270,1700
  96. 1360 [145]tj[171]9[137]1720,1700,1270
  97. 1370 [145]tj[171]9[137]1510,1480,1700
  98. 1380 [145]tj[171]9[137]1480,1480,1700
  99. 1390 [153][163]60)a1$" is"sj"  ok?":[146]k,15:[161]a$
  100. 1395 [139]a$[178]"n"[167]ef[178]6:[142]
  101. 1400 [137]1020
  102. 1410 [139]sj[178]tj[167]1270
  103. 1420 [139]sj[179]10[167]ef[178]6:[142]
  104. 1430 [141]1900:[139]a1[178].[167]ef[178]6:[142]
  105. 1440 nc[178]nc[170]1:cs$(nc)[178]a1$[170]" must be"[170][196](tj)
  106. 1445 u(tj)[178]1:l(i)[178]1:tr(i)[178]tj:so(i)[178]tj
  107. 1450 [129]n[178]1[164]nm:[139]i[178]n[167]1470
  108. 1460 [139]tj[178]so(n)[167]ef[178]5:[142]
  109. 1470 [130]:[137]1020
  110. 1480 so(i)[178]tj:nc[178]nc[170]1:cs$(nc)[178]a1$[170]" must be "[170]cs$(tj[170]16)
  111. 1490 :
  112. 1500 [137] 1020
  113. 1510 ef[178]6:[142]
  114. 1530 a[178][197](a$):[139]a[179]1[176]a[177]r[167]1270
  115. 1532 [153]"open",,xx$
  116. 1540 [153],,"on(NULL)ine"a"cmd:  "rw$(a)
  117. 1542 [153],,xx$:[153],,"(NULL)ell me.. is it:  "
  118. 1544 [153],,"a  even           "
  119. 1546 [153],,"b  odd            "
  120. 1548 [153],,"c  prime          "
  121. 1550 [153],,"d  not prime      "
  122. 1552 [153],,"e  square         "
  123. 1554 [153],,"f  not square      "
  124. 1556 [153],,"0  none of these   "
  125. 1560 [153],,xx$:[153],,"(NULL)lease press a key.list
  126. 1565 waitk,15:getb$
  127. 1570 gosub10200:b=asc(b$)-64:i=co(a,1):ifb<1orb>6then1270
  128. 1580 ifb>2then1600
  129. 1590 nc=nc+1:cs$(nc)=rw$(a)+" is "+cs$(25+b):tj=9+b
  130. 1595 a1$=un$(i):goto1310
  131. 1600 b=b-2:cl(a)=b:poke50288+a,b:nc=nc+1:cs$(nc)=rw$(a)+" is "+cs$(b+20)
  132. 1610 iflen(rw$(a))<9then1620
  133. 1615 cl(a)=.:print"[195]an't be sure":cs$(nc)=cs$(nc)+"..?
  134. 1620 [139]b[178]1[167][139][195](rw$(a))[178]1[167]1690
  135. 1630 [145]b[137]1640,1020,1670,1020
  136. 1640 [145]so(i)[170]1[137]1510,1020,1510,1020,1510,1510,1510,1020,1510,1020
  137. 1645 [145]so(i)[171]9[137]1510,1660,1700
  138. 1650 [139]so(i)[178]16[167]1510
  139. 1660 so(i)[178]14:[137]1020
  140. 1670 [145]so(i)[170]1[137]1020,1020,1510,1510,1020,1020,1020,1510,1510,1020
  141. 1680 [145]so(i)[171]9[137]1020,1020,1700,1710,1510,1710
  142. 1690 [145]so(i)[170]1[137]1510,1020,1020,1020,1510,1020,1510,1020,1510,1510
  143. 1695 [145]so(i)[171]9[137]1720,1020,1020,1020
  144. 1700 so(i)[178]1:tr(i)[178]1:u(1)[178]1:l(i)[178]1:nc[178]nc[170]1:cs$(nc)[178]un$(i)[170]" is 1":[137]1450
  145. 1710 so(i)[178]16:[137]1020
  146. 1720 so(i)[178]2:tr(i)[178]2:u(2)[178]1:l(i)[178]1:nc[178]nc[170]1:cs$(nc)[178]un$(i)[170]" is 2":[137]1450
  147. 1900 a1[178].:[145] sj[171]9[137]1910,1910,1920,1940,1950,1960,1970
  148. 1910 a1[178]sj[170]tj[170]1[175]1:[142]
  149. 1920 [139]tj[179]3[167]a1[178]tj
  150. 1930 [142]
  151. 1940 a1[178]1:[142]
  152. 1950 a1[178][182](3[171][182](tj[171]5))[178]1:[142]
  153. 1960 a1[178]tj:[142]
  154. 1970 a1[178][182](k2[171][182](tj[171]5))[171]k1:[142]
  155. 2000 [129]i[178]1[164]r
  156. 2010 n[178]cl(i):[139]n[178].[176]n[177]4[167]2080
  157. 2020 a[178].:c[178]10
  158. 2030 [129]a1[178][195](rw$(i))[164]1[169][171]1:a[178]c[172]a[170]tr(co(i,a1)):[130]
  159. 2040 [139]n[177]2[167]2070
  160. 2050 [141]7800:[139]n[170](a1[177].)[178]1[167]2080
  161. 2060 ef[178]c:[142]
  162. 2070 b[178][181]([186](a)[172]a2):[139] n[178]3[171](a[178]b[172]b) [167] ef[178]c:[142]
  163. 2080 [130]
  164. 2090 ef[178].:[142]
  165. 2200 a[178]36:s[178]s[170]1:a$[178]""
  166. 2210 [153]""[163]16)s""
  167. 2220 [129]i[178]1[164]nm
  168. 2230 [153][163]a)tr(i)
  169. 2240 [130]
  170. 2250 b[178]s[171]20[172][181]((s[171]1)[173]20)
  171. 2260 [129]i[178]1[164]nm:sl(b,i)[178]tr(i):[130]
  172. 2270 [129]a1[178]1[164]lr:a$[178][201]([196](tr(co(r,a1))),1)[170]a$:[130]
  173. 2280 sl$(b)[178]a$
  174. 2300 [139][194](829)[167][141]11900
  175. 2330 [139][194](832)[170][194](k)[178].[167][142]
  176. 2340 [161]a$:[141]12000
  177. 2400 [139]re[178]1[167][142]
  178. 2410 [139]re[178]3[167][151]832,1[171][194](832):[137]6900
  179. 2420 [139]re[178]5[167][151]832,[194](832)[176][194](829):[151]829,1[171][194](829):[137]6900
  180. 2430 [142]
  181. 4000 cs$(1)[178]"prime":cs$(2)[178]"odd":cs$(3)[178]"even":cs$(4)[178]"square":cs$(5)[178]"not sqr
  182. 4010 m1$="[150][198]1 [205]ore analysis":sj=1
  183. 4020 print"[147][150]  [208]uzzle [193]nalysis:
  184. 4030 [153]"  ================list
  185. 4040 print" #  "rw$(r)tab(14)"factor square
  186. 4050 [129]i[178]sj[164]sj[170]19
  187. 4060 [153]sj[163]4)ts$(sj);
  188. 4070 a[178][197](ts$(sj)):[141]7800
  189. 4080 [139]a1[177]2[167]a1[178]1
  190. 4090 b[178][181]([186](a)[172]a2)
  191. 4100 [153][163]14)cs$(a1[170]1)[163]21)cs$((a[178]b[172]b)[170]5)
  192. 4110 [139]sj[177][178]s[167][153]x$;:[142]
  193. 4120 sj[178]sj[170]1
  194. 4130 [130]
  195. 4140 [139]sj[177]59[167][153]x$;:[142]
  196. 4150 [139]sj[179][178]s[167][153]"...more";
  197. 4200 [141]12310
  198. 4210 [139](re[178]1)[172](sj[179][178]s)[167]4020
  199. 4220 [142]
  200. 4300 [139]s[179]61[167][129]i[178]1[164]b:ts$(i[170]s[171]b)[178]sl$(i):[130]:[142]
  201. 4310 x$[178]"end memory":[142]
  202. 4500 [160]1:[159]1,8,15
  203. 4510 [160]2:[159]2,8,8,"puzzles.tst
  204. 4520 input#1,a,b$
  205. 4530 ifa>19thenprint:input"[206]eed program disk";a$:close2:close1:run200
  206. 4540 get#2,a$:r=asc(a$)
  207. 4600 fori=1tor
  208. 4610 input#2,rw$(i)
  209. 4620 rt(i)=12-len(rw$(i))
  210. 4630 next
  211. 4640 b$="":nc=.:za=.:zb=.:cs$(1)="":input#2,b$
  212. 4650 ifb$>" "thencs$(1)=mid$(b$,3):za=asc(b$):zb=asc(mid$(b$,2)):nc=1
  213. 4660 lr=len(rw$(r)):cc=.
  214. 4670 get#2,a$:aa=asc(a$+chr$(0))
  215. 4700 print"[147]":gosub14000
  216. 4705 ifaa=.thenprint"[204]ast puzzle![155]
  217. 4710 [153]" asc1  atnccept this
  218. 4720 ifaathenprint" [198]3  [206]ext puzzle
  219. 4730 [153]" asc5  (NULL)uit
  220. 4750 gosub 12900
  221. 4760 ifre=3thenifaathenr=aa:goto4600
  222. 4770 close2:c