- 2022-12-30 – Update to Jason’s final version to make it two bytes smaller.
In this final (?) installment, I wanted to share some other approaches that were taken to by members of the CoCo community draw this:
…including one that immediately was smaller than the version I did.
Rick Adams – PDP8/I
Early on, a version was shared by legendary CoCo programmer Rick Adams. His version was not for the CoCo – he chose to do it “in a very primitive BASIC, BASIC8 on a simulated PDP8/I running the TSS8 OS”…
0 'RICK ADAMS 12 FOR B = 1 TO 4 14 GOSUB 2000 20 NEXT B 22 C = 0 24 D = 0 30 FOR I = 1 TO 9 32 READ A, B 34 GOSUB 1000 36 NEXT I 50 FOR B = 4 TO 1 STEP -1 52 GOSUB 2000 58 NEXT B 200 DATA 0, 17, 1, 15, 2, 13, 3, 11, 4, 9, 3, 11, 2, 13, 1, 15, 0, 17 300 STOP 1000 PRINT TAB(A); 1010 FOR J = 1 TO B 1020 PRINT "*"; 1030 NEXT J 1040 PRINT TAB(A + B + C); 1050 FOR J = 1 TO D 1060 PRINT "*"; 1070 NEXT J 1080 PRINT 1090 RETURN 2000 A = 4 2002 D = B 2010 C = 9 - 2 * B 2020 GOSUB 1000 2030 RETURN 2046 END
I am unfamiliar with the BASIC on this machine, but at least it doesn’t require using “LET“. This version can run on the CoCo as well, and correctly reproduces the pattern.
Jim Gerrie – MC-10/CoCo
Next, take a look a this one by MC-10 BASIC-meister, Jim Gerrie:
His approach uses DATA statements and then draws the star in an interesting way.
In the comments on an earlier installment, Jason shared his attempt. His approach was realizing that the shape was just “four overlapping right triangles.”
This version is just 100 bytes! Due to the CoCo’s 32 column screen being too short, it doesn’t draw the top and end lines of the pattern, so it wouldn’t meet the challenge requirements. To fix that, he needed to add an IF:
1 FORX=32TO416STEP32:L=X/32:T$=STRING$(L,42):PRINT@X-28,T$;:PRINT@(X-19-L),T$;:IF X>32THEN PRINT@544-X+4,T$;:PRINT@557-X-L,T$; 2 NEXT 3 GOTO3
Since the CoC 3 also has a 40×24 and 80×24 screen, the entire pattern could fit on those screens. Version three looked like this:
That one is a mere 88 bytes! And, the GOTO1 at the end is just to make it keep redrawing, else it stops near the top and would print the “OK” in the middle of the pattern.
I’d say the “WIDTH40:” is not required, since you could just say “run this from the 40 column screen.” And, to keep the loop, starting on LINE 0 allows just saying “GOTO” with no line number:
By my count, that turns in to 83 bytes! Amazing.
UPDATE: L. Curtis Boyle pointed out there was an unnecessary “+L” left in the code, which can be removed to make this 81 bytes. More amazing!
Here is what it looks like, though I paused it to capture the full image:
Please read his comments to part 1 for more background and earlier versions he shared.
I’m really blown away by this.
Are we done? Is this as small as it gets?
Unless there are more ideas, I think that is the end.
Merry Christmas, everyone!