VCCC2023: Christmas Challenge

bbc micro/electron/atom/risc os coding queries and routines
User avatar
dominicbeesley
Posts: 2210
Joined: Tue Apr 30, 2013 12:16 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dominicbeesley »

Did you enter those rtw? I didn't spot them in the video...I thought I'd got the third smallest BASIC program but evidently not.


I have up optimising when I got to 53 bytes which is &35... seemed nice and symmetrical.
User avatar
JohnH
Posts: 85
Joined: Thu Aug 11, 2016 10:59 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by JohnH »

10a=2858:b=2602:FORX=8TO20STEP6:FORY=8TO20STEP6:VDU31,X,Y,a;a;a;b;b;b;7978;X,Y,b;b;b;a;a;42:NEXT,

84 bytes. I like it but I failed in my hopes of being less than twice the smallest. Although I am not twice the size of the smallest BBC basic which is a relief :lol:

a is asterisk, cursor up. b is asterisk, cursor down and 7978 is asterisk, 31. I thought the use of the semi-colon syntax to send two bytes was quite nice and saved a few commas. I could've centered it but that might've increased it by a couple of bytes.

I like yours RTW =D> , I'll have to do the maths to figure it out.

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... T%2C%22%7D
dp11
Posts: 1757
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dp11 »

JohnH wrote: Sat Dec 30, 2023 10:18 pm 10a=2858:b=2602:FORX=8TO20STEP6:FORY=8TO20STEP6:VDU31,X,Y,a;a;a;b;b;b;7978;X,Y,b;b;b;a;a;42:NEXT,

84 bytes. I like it but I failed in my hopes of being less than twice the smallest. Although I am not twice the size of the smallest BBC basic which is a relief :lol:
I'm afraid David Payne's BBC BASIC entry was 41 bytes See time 35:33 in the video
User avatar
dominicbeesley
Posts: 2210
Joined: Tue Apr 30, 2013 12:16 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dominicbeesley »

I've just tried having a go using all the combined hindsight available and I can't beat David's 41 in BBC BASIC...can any one else....there must be a byte to be had somewhere but I can't see it!
User avatar
hoglet
Posts: 12666
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: VCCC2023: Christmas Challenge

Post by hoglet »

dominicbeesley wrote: Sat Dec 30, 2023 11:00 pm I've just tried having a go using all the combined hindsight available and I can't beat David's 41 in BBC BASIC...can any one else....there must be a byte to be had somewhere but I can't see it!
I can...
xmas2023.png
User avatar
dominicbeesley
Posts: 2210
Joined: Tue Apr 30, 2013 12:16 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dominicbeesley »

EOR... #-o

Nice!
User avatar
flaxcottage
Posts: 5718
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: VCCC2023: Christmas Challenge

Post by flaxcottage »

Very nice indeed. Once given the idea I shaved two bytes off the code and it still is within the rules, I think.
code.jpg
What is irksome is that the fossilisation of the intellect from which I suffer prevented me from seeing this solution in the first place. :(

I went down the VDU28 route and that was over twice as long but quicker.
mine.jpg
- John

Check out the Educational Software Archive at www.flaxcottage.com
dp11
Posts: 1757
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dp11 »

I'd say requiring the CLS before running was pushing the boundaries why not go the whole hog and prepare the picture in memory and just copy it across.
User avatar
Rich Talbot-Watkins
Posts: 2054
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: VCCC2023: Christmas Challenge

Post by Rich Talbot-Watkins »

dominicbeesley wrote: Sat Dec 30, 2023 8:01 pm Did you enter those rtw? I didn't spot them in the video...I thought I'd got the third smallest BASIC program but evidently not.
No, I didn't bother! Just thought I'd keep it here on Stardot where it matters :wink:

Just shrunk mine down to 47 bytes using that great EOR/AND trick to avoid needing extra brackets! But that's where I stop.

Owlet

Code: Select all

FORy=0TO18:FORx=3TO21:VDU9EOR35AND(x*x-y*y)MOD6=0:NEXT:PRINT:NEXT
User avatar
flaxcottage
Posts: 5718
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: VCCC2023: Christmas Challenge

Post by flaxcottage »

dp11 wrote: Sun Dec 31, 2023 10:07 am I'd say requiring the CLS before running was pushing the boundaries why not go the whole hog and prepare the picture in memory and just copy it across.
Thought about that but it needs too much data, which had to be declared and included in the total size.

Can't use RUN|L or RUN|Z because they move VPOS. Using CLS:RUN puts these commands in the keyboard buffer so that CLS zeroes VPOS and POS; RUN is executed and the change of VPOS due to the [CR] is executed after the program has run. At least that's what I think happens.

Yes, the boundary is being pushed, I agree, but just a little bit. After all every little counts when saving a byte or two.

Nevertheless the original solution is really elegant. =D>
- John

Check out the Educational Software Archive at www.flaxcottage.com
User avatar
BeebMaster
Posts: 7380
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: VCCC2023: Christmas Challenge

Post by BeebMaster »

I think doing CLS:RUN is within the rules, it doesn't specify that the screen must be cleared when running, and some of the entries have the pattern drawn over the start-up screen anyway.

I think what wouldn't be allowed would be declaring all the variables on the command line then a GOTO, eg. A=6:B=6:CLS:GOTO10 would be cheating a bit.
Image
dp11
Posts: 1757
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by dp11 »

But this program won't work without the CLS. So I would say that it fundamental to its operation
User avatar
hoglet
Posts: 12666
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: VCCC2023: Christmas Challenge

Post by hoglet »

BeebMaster wrote: Sun Dec 31, 2023 12:04 pm I think doing CLS:RUN is within the rules, it doesn't specify that the screen must be cleared when running, and some of the entries have the pattern drawn over the start-up screen anyway.
I would argue that in the case of solutions like this:

Code: Select all

    1CLS:REPEATVDU9EORABS(VPOS^2-POS^2)MOD6=3ANDPOS<19AND35:UNTILVPOS>18
the CLS needs to be included, because the program doesn't work correctly if the cursor doesn't start in the top left corner.

(Edit: snap)

Dave
User avatar
BeebMaster
Posts: 7380
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: VCCC2023: Christmas Challenge

Post by BeebMaster »

Fair enough. In my case, with absolute co-ordinates using PRINTTAB it didn't matter if the screen was cleared or not for the cursor position.
Image
User avatar
Rich Talbot-Watkins
Posts: 2054
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: VCCC2023: Christmas Challenge

Post by Rich Talbot-Watkins »

hoglet wrote: Sun Dec 31, 2023 12:23 pm

Code: Select all

    1CLS:REPEATVDU9EORABS(VPOS^2-POS^2)MOD6=3ANDPOS<19AND35:UNTILVPOS>18
Just noticed that this one works in fundamentally the same way as mine, using a*a-b*b mod 6 as the condition for drawing a star vs a space. Bravo!
User avatar
hoglet
Posts: 12666
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: VCCC2023: Christmas Challenge

Post by hoglet »

Rich Talbot-Watkins wrote: Sun Dec 31, 2023 2:15 pm
hoglet wrote: Sun Dec 31, 2023 12:23 pm

Code: Select all

    1CLS:REPEATVDU9EORABS(VPOS^2-POS^2)MOD6=3ANDPOS<19AND35:UNTILVPOS>18
Just noticed that this one works in fundamentally the same way as mine, using a*a-b*b mod 6 as the condition for drawing a star vs a space. Bravo!
This is David Payne's entry (which won the smallest BASIC program category), plus a small change by me to save one further byte.
julie_m
Posts: 587
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: VCCC2023: Christmas Challenge

Post by julie_m »

I must confess, I forgot all about POS and VPOS, so I never even considered a BASIC solution might come out smaller!

I thought I had clinched it with my cunning use of numbers in the lookup table that would sum to exactly 41 wherever a star was to be printed, and then using SEC to add an extra 1 giving 42 -- the ASCII code for * -- or printing a space otherwise.
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: VCCC2023: Christmas Challenge

Post by BigEd »

Diminished wrote: Sat Dec 30, 2023 7:10 pm Well, my animated wild entry wasn't even shown moving in the results video…
I see though that you are the first featured in the wild compo video
https://youtu.be/IbeVP_pDOPk?si=LDP3TXUZlkwB9ULa
julie_m
Posts: 587
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: VCCC2023: Christmas Challenge

Post by julie_m »

Well, I actually managed to get the machine code version down to just 38 bytes, using a slightly dirty technique .....

Owlet Link

Is that even within the spirit of the rules? Can you stomp on memory outside of your program and not claim it as part of what you're using?
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: VCCC2023: Christmas Challenge

Post by BigEd »

I don't see what might be wrong with what you're doing there - from pattern to P% is all the initialised memory, I think? Looks pretty neat and tidy! (Can't get my head around what you're doing with O% though... is there something going on there?)
julie_m
Posts: 587
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: VCCC2023: Christmas Challenge

Post by julie_m »

The Owlet version assembles directly at P%, so the code can be run in-situ. The original assembled the code offset, because technically it was trespassing on a bit of zero page that neither BASIC nor MOS seem to write anything to but isn't advertised as available for the user, and required it to be run from disc. There may be vestigial organs left over from an ancestor's niche :)

EDIT: Also, 37 bytes.
User avatar
BeebMaster
Posts: 7380
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: VCCC2023: Christmas Challenge

Post by BeebMaster »

Last year, or the year before, I used @% to store a string variable, as it was the only existing variable I could use where the location was guaranteed (ie. &90A) to be available to store data, without having to declare a new variable or do a DIM, and I didn't get arrested or banned.
Image
User avatar
jgharston
Posts: 5321
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: VCCC2023: Christmas Challenge

Post by jgharston »

All these put my 107 bytes to shame. :( I never thought of relying on the display position, I just outputted directly on from wherever the program started.

Code: Select all

   10 FORA%=0TO18:L=ABS(A%MOD6-3):IFL=0:PRINT"*  ";
   20   IFL=3ORL=0:PRINTSPC3"*"SPC5"*"SPC5"*"ELSEIFL=1:PRINTSTRING$(3," *   *")ELSEIFL=2:PRINTSTRING$(3,"  * * ")
   30 NEXT
It did take a couple of Doh! moments to realise some of the optimisations. Going ABS(minus to plus) to get a triangle wave is something I commonly do, yet I forgot almost until the last moment with this. And it took a silly amount of time to realise the L=0 state could be shared with the L=3 state.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
User avatar
jgharston
Posts: 5321
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: VCCC2023: Christmas Challenge

Post by jgharston »

For my wildcard, I took the demo exactly as specified:
allrun.gif

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
SidewayRum
Posts: 10
Joined: Sat Jul 16, 2022 6:00 pm
Contact:

Re: VCCC2023: Christmas Challenge

Post by SidewayRum »

I had a lot of fun, it was my first attempt at "pro" coding and I'm surprised not being the last... and not the last Beeb BASIC entry too. As I thought the screen had to be cleaned, a CLS slipped in. No way for me to find any math logic in the design, gone brute force with strings :lol: . I'd like to do more of that stuff, it's gratifying even if you don't win.
Post Reply

Return to “programming”