diamond pattern (BASIC) 1.1 Author: David Payne Category: Christmas Challenge 2023 System: BBC Micro Language: BBC BASIC Len source code: 41 bytes Len exe file: 41 bytes Len code only: 41 bytes Instructions: Save the VCCC.ssd file on your local PC From the https://bbc.godbolt.org website click on Discs From examples or local Choose file select the saved VCCC.ssd file enter CHAIN"PROGRAM" Description: The diamond pattern is 19x19 characters (0 to 18 in the screen coordinates) the x coordinate is translated into a number from the below table (e.g. x=0 -> 3) 3210123210123210123 the y coordinate is translated into a number from the above table (e.g. y=1 -> 2) when one of the numbers is 3 and the other one is 0 OR when one of the numbers is 2 and the other one is 1 output an asterisk else output a space or more simply... when the 2 numbers add up to 3 output an asterisk else output a space the one-line program is 1CLS:REPEATVDU32ORABS(POS MOD6-3)+ABS(VPOS MOD6-3)=3ANDPOS<19AND10:UNTILVPOS>18 CLS clears the screen the REPEAT/UNTIL loop gives us 19 rows POS and VPOS give the cursor x and y ABS(POS MOD6-3)+ABS(VPOS MOD6-3)=3 calculates the 2 numbers and checks that their sum is equal to 3 POS<19 gives us 19 columns (it outputs trailing spaces rather than new lines) the expression 32 OR ABS(POS MOD6-3)+ABS(VPOS MOD6-3)=3 AND POS<19 AND 10 (spaces added for clarity) gives us 42 (asterisk) or 32 (space) and we simply output this character to the screen (VDU) 10 days later... I was messing around with the code and I managed to find an alternative (but shorter) expression for the same pattern: I replaced: ABS(POS MOD6-3)+ABS(VPOS MOD6-3)=3 with: ABS(VPOS^2-POS^2)MOD6=3 (^ = raise to the power of) The program runs slower, but more importantly, it is 7 bytes shorter The program is now: 1CLS:REPEATVDU32ORABS(VPOS^2-POS^2)MOD6=3ANDPOS<19AND10:UNTILVPOS>18 Comments: Thanks to Logiker for organising another fun contest and a Happy Christmas to all contestants 1CLS:REPEATVDU32ORABS(VPOS^2-POS^2)MOD6=3ANDPOS<19AND10:UNTILVPOS>18