10 REM"BEWARE!!" Don't renumber - this confuses calculated GOTOs. 20 REM Program to find number of combinations of coins possible to make `4-99. 30 REM J.Davis '94. 40 REM Program calculates all 5's, 2's, and 1's at one go after each new 10 or larger. 100 MODE7:VDU23,1,0,0;0;0;0; 110 PRINTTAB(9);CHR$(141);CHR$(131);"`4-99 COMBINATIONS" 120 PRINTTAB(9);CHR$(141);CHR$(131);"`4-99 COMBINATIONS" 130 PRINTCHR$(145);STRING$(39,"s") 140 PRINT" This is a sit-back-and-watch-gosh- isn't-it-time-for-a-cup-of-tea-yet-or- maybe-something-stronger type of program." 150 PRINT" Once upon a time I was expecting a COD delivery of unknown amount and wondered if I had the right coins to make any amount between 1p and `4-99." 160 PRINT"This was easy to arrange. Then, for no very good reason, I wondered how many different ways there were to make exactly `4-99. That's what this programworks out." 170 PRINT" The first combination is all pennies,the second is 1x2p and 497x1p, the third is 2x2p and 495x1p etc., to a final pattern of 4x100p, 1x50p, 2x20p, 1x5p, and 2x2p." 180 PRINTTAB(27);"PRESS SPACE" 190 PRINTCHR$(145);STRING$(39,"s"); 200 G=GET:CLS 210 PRINTCHR$(145);STRING$(39,"s") 220 PRINT" The first version of this program, where the computer counted each combination on its fingers, took a day and a half to run. This final version is much quicker, and displays what it'sdoing as it runs." 230 PRINT" For each new pattern of 10's, 20's, 50's, and 100's, as displayed, it calculates, with a curious loop, all the possible combinations of 1's, 2's, and 5's to make `4-99."; 240 PRINT" This gives the increase of each new 'Total So Far'." 250 PRINT" There may be a formula to calculate the result instantly, but that would spoil the fun!" 260 PRINT" Try to guess the result - very roughly - before running the program. A guess within +/-25% is very good." 270 PRINT:PRINTTAB(26);"PRESS SPACE" 280 PRINTCHR$(145);STRING$(39,"s"); 290 G=GET 400 CLS 410 PRINTTAB(0,10);CHR$(145);STRING$(39,"s") 420 PRINTTAB(9);CHR$(141);CHR$(131);"`4-99 COMBINATIONS" 430 PRINTTAB(9);CHR$(141);CHR$(131);"`4-99 COMBINATIONS" 440 PRINT 450 PRINTCHR$(145);STRING$(39,"s") 500 : 510 TIME=0 520 DIMA(10) 530 DIMB(100) 540 A(1)=1:A(2)=2:A(3)=5:A(4)=10:A(5)=20:A(6)=50:A(7)=100 550 F=1:BT=0 560 C=0:CA=0 570 VDU15 580 GOTO2000 590 BT=0:F=0 600 F=F+1 610 IFB(F)=A(G) THEN GOTO G*1000 620 BT=BT+B(F) 630 GOTO600 1990 REM Calculates 1's, 2's, and 5's. 2000 CA=CA+1 2010 L=(500-BT)/5 2020 X=(-1) 2030 M=2:N=0:P=0 2040 FORK=1TOL 2050 X=X*(-1) 2060 M=M+X 2070 N=N+M 2080 P=P+N 2090 NEXT 2100 C=C+P 2110 PROCprint 2120 B(F)=5 2130 G=3 2140 GOTO590 2990 REM Adds 10's, 20's, 50's, & 100's 3000 B(F)=10 3010 BT=BT+10 3020 IFBT>499THENG=4:GOTO590 3030 B(F+1)=2 3040 G=2 3050 GOTO600 4000 B(F)=20 4010 BT=BT+20 4020 IFBT>499THENG=5:GOTO590 4030 B(F+1)=2 4040 G=2 4050 GOTO600 5000 B(F)=50 5010 BT=BT+50 5020 IFBT>499THENG=6:GOTO590 5030 B(F+1)=2 5040 G=2 5050 GOTO600 6000 B(F)=100 6010 BT=BT+100 6020 IFBT>499 THEN PROCend:PROCtime:G=GET:VDU23,1,1,0;0;0;0;:END 6030 B(F+1)=2 6040 G=2 6050 GOTO600 13990 : 14000 DEFPROCprint 14010 PRINT" ";CA 14020 FORK=1TOF-1 14030 PRINTB(K); 14040 NEXT 14050 PRINT:PRINT 14055 : 14060 PROCcommas 14070 PRINTCHR$(141);CHR$(129);"TOTAL SO FAR=";CHR$(131);TA$ 14080 PRINTCHR$(141);CHR$(129);"TOTAL SO FAR=";CHR$(131);TA$ 14090 PRINT 14100 PRINTCHR$(148);STRING$(39,"s") 14110 ENDPROC 14990 : 15000 DEFPROCtime 15010 T=INT(TIME/100) 15020 PRINT:PRINT 15030 PRINTCHR$(134);" TIME= ";(T)DIV60;"min ";(T)MOD60;"sec" 15040 PRINTCHR$(145);STRING$(39,"s") 15050 VDU7 15060 ENDPROC 15065 : 15070 DEFPROCend 15080 PROCcommas 15090 PRINTCHR$(141);CHR$(129);"WHEW!!" 15100 PRINTCHR$(141);CHR$(129);"WHEW!!" 15110 PRINT 15120 PRINTCHR$(141);CHR$(131);"GRAND TOTAL= ";TA$;" COMBINATIONS" 15130 PRINTCHR$(141);CHR$(131);"GRAND TOTAL= ";TA$;" COMBINATIONS" 15140 PRINT:PRINT" Not a lot of people know that." 15150 ENDPROC 15155 : 15160 DEFPROCcommas 15165 TA$="" 15170 T$=STR$(C) 15180 L=LEN(T$)-3 15190 FORN=1TOL 15200 TA$=TA$+MID$(T$,N,1) 15210 IF(L-N)MOD3=0 THEN TA$=TA$+"," 15220 NEXT 15225 TA$=TA$+RIGHT$(T$,3) 15230 ENDPROC