The Christmas Star Challenge

The Vintage Computing Christmas Challenge 2022 (VC³ 2022), a nice programming competition organized by Logiker for the Christmas period, has just ended.

The objective of the main challenge, called Christmas Star Challenge, consists in the creation of a program for any computer and language (preferably vintage systems), capable of faithfully representing the figure shown in the picture below, either optimizing the code as much as possible, or improving it.

The Christmas Star expected output
The Christmas Star (source: Logiker)

Alternatively, by opting for the Wild challenge, it was possible to create a completely different program, as long as it had a Christmas theme.

Hundreds of people joined the challenge and all the entries are presented in this video, created by the organizer:

Video by Logiker presenting all the entries to the Vintage Computer Christmas Challenge 2022.

My Christmas Star implementation in Tiny BASIC

I decided to participate in the Christmas Star Challenge by making a program in Tiny BASIC. The star spans over a 17 characters wide square and can be divided into four overlapping triangles:

01    *            
02    **           
03    ***          
04    ****         
05    *****        
06    ******       
07    *******      
08    ********     
09    *********    
10    **********   
11    ***********  
12    ************ 
13    *************
14
15
16
17
01            *    
02           **    
03          ***    
04         ****    
05        *****    
06       ******    
07      *******    
08     ********    
09    *********    
10   **********    
11  ***********    
12 ************    
13*************    
14
15
16
17
01
02
03
04
05*************    
06 ************    
07  ***********    
08   **********    
09    *********    
10     ********    
11      *******    
12       ******    
13        *****    
14         ****    
15          ***    
16           **    
17            *    
01
02
03
04
05    *************
06    ************ 
07    ***********  
08    **********   
09    *********    
10    ********     
11    *******      
12    ******       
13    *****        
14    ****         
15    ***          
16    **           
17    *            

Thus, the idea is to iterate over each of the 17*17 positions and print a “*” character if the considered “point” belongs to at least one of the 4 triangles and an empty space ” ” otherwise:

 100 LET R=0
 110 LET C=0
 120 LET S=0
 130 IF R<13 THEN IF C>3 THEN IF C<R+5 THEN LET S=1
 140 IF R<13 THEN IF C<13 THEN IF C>11-R THEN LET S=1
 150 IF R>3 THEN IF C<13 THEN IF C>R-5 THEN LET S=1
 160 IF R>3 THEN IF C>3 THEN IF C<21-R THEN LET S=1
 800 IF S=0 THEN PRINT " ";
 810 IF S=1 THEN PRINT "*";
 900 LET C=C+1
 910 IF C<17 THEN GOTO 120
 915 PRINT
 920 LET R=R+1
 930 IF R<17 THEN GOTO 110
1000 END

By removing the unnecessary spaces and taking advantage of Tiny BASIC instructions abbreviations, I managed to reduce the size of the program listing to 203 characters:

1R=0
2C=0
3S=0
4IFR<13IFC>3IFC<R+5S=1
5IFR<13IFC<13IFC>11-RS=1
6IFR>3IFC<13IFC>R-5S=1
7IFR>3IFC>3IFC<21-RS=1
8IFS=0PR" ";
9IFS=1PR"*";
10C=C+1
11IFC<17GOTO3
12PR
13R=R+1
14IFR<17GOTO2
15END

And here is the output:

    *       *    
    **     **    
    ***   ***    
    **** ****    
*****************
 *************** 
  *************  
   ***********   
    *********    
   ***********   
  *************  
 *************** 
*****************
    **** ****    
    ***   ***    
    **     **    
    *       *    

I haven’t found a way to optimize further the program before the end of the challenge; any suggestions are welcome!

In the following video, you can see the program running on a Cosmac ELF computer, emulated with Emma 02.

My Tiny BASIC implementation of the Christmas Star, running (slowly) on the Cosmac ELF, emulated with Emma 02.

You can also run it and/or modify the code using the TinyBASICBlazor online interpreter.

My Tiny BASIC implementation of the Christmas Star, running on TinyBASICBlazor, the Tiny BASIC interpreter for web browsers.

Evolutions / other versions

Due to the simplicity of the Tiny BASIC syntax, which can be considered as a subset of most BASIC dialects, the program can be run on a variety of platforms without any modifications (e.g. BBC Basic) or with minimal modifications. For example, on the Sinclair ZX81 it is sufficient to remove the “END” statement or replace it with “STOP”.

My implementation of the Christmas Star running in BBC BASIC for SDL.
My Tiny BASIC implementation of the Christmas Star running in BBC BASIC for SDL.

As for the little Sinclair computer, I tried to further reduce the size of my original Tiny BASIC code, although to get better results in terms of size, it would have been necessary to completely rewrite it, taking advantage of Sinclair BASIC peculiarities.

Sinclair ZX81 Christmas Star program listing.
Sinclair ZX81 Christmas Star program listing.
Sinclair ZX81 Christmas Star
Sinclair ZX81 Christmas Star.
Sinclair ZX81 Christmas Star in action.

Finally, since the main purpose of the competition was to have fun, I made a Teletext version of the Christmas Star, which reproduces the reference image of the challenge:

The Christmas Star, Teletext version.
The Christmas Star, Teletext version.

The ranking sorted by source code size is available, together with the downloads of all entries, on demozoo.org.
Congratulations to Dr. BEEP, who won the first positions with the assembly versions for ZX81 and ZX Spectrum, whose code size is only 27 and 29 bytes respectively!

Leggi in Italiano

Leave a comment

Your email address will not be published. Required fields are marked *