Christmas Snowflake Author: Matt Pilz Category: Christmas Challenge System: Commodore C64 Language: BASIC Len source code: 187 Len exe file: 191 Instructions: [EMULATION] 1. Download the latest VICE emulator from https://vice-emu.sourceforge.io/index.html#download (e.g., v3.9). 2. Extract the contents to your hard drive and launch the executable (e.g., x64sc.exe). 3. Select File > Smart Attach (ALT+A) and double-click xmas25.prg. 4. Type RUN and then press . [ORIGINAL HARDWARE] 1. Transfer "xmas25.wav" to a device for audio playback. This can be a cassette, laptop, phone etc. 2. Power-up your Commodore 64 and at the BASIC prompt, type LOAD and then press . 3. Begin playback of the audio file while connected to the Commodore audio interface. After several seconds the data should load and you should see a "READY" prompt. If not, try increasing the volume of playback. 4. Once loaded, type RUN and then press . Description: For this challenge, I felt it would be fun and creative to embrace the system's internal random number generator (RNG) as part of producing the necessary output. I first determined which seed could generate the star pattern for each row of the top-left of the snowflake by brute force iterating through every seed until a match was found. This was done by generating a 0 or 1 randomly and comparing it to the necessary pattern. For example, row 3 equates to " * * **" so I searched for a seed that would generate its first 10 random numbers in the order of "0010100011" and then noted the seed value. This was done for 10 rows, 10 characters each, to encapsulate the full top-left of the design. For the top-right, it is simply a reverse pattern from the base. Same for the bottom half of the snowflake, except for that we also iterate through the rows in reverse order. So from 10 statically set seeds we are able to produce the full 19x19 pattern snowflake. The foundational code can then remain largely the same when porting to other platforms, with the only difference being which seeds produce the desirable output as depicted within the DATA statement of the final code. Comments: The following files are included in this package. * xmas25.txt Text format source code * xmas25.bin Raw binary composed only of the tokenized BASIC code (187 bytes) * xmas25.prg Emulation-supported loadable BASIC program * xmas25.tap Tape formatted output of the program for tape-based playback on emulation etc. * xmas25.wav Audio output of the program for playback on a real device * source.png Complete program listing as seen on the Commodore 64 * result.png Output of the program after running it on the Commodore 64