Post Reply 
Advents of Code (programming challenges)
12-10-2022, 11:38 AM (This post was last modified: 12-10-2022 11:46 AM by pier4r.)
Post: #12
RE: Advents of Code (programming challenges)
semi OT regarding the Ram, there is someone solving the problems on an apple 2c

https://github.com/colinleroy/aoc2022 (using basic)

Seemingly the thing has the same ram available (to the user) like the HP 50g, if not less.

Quote:Now that's complicated. Memory's limited and I can't use as many arrays as I want to. DIM A(100,100) directly gives an OUT OF MEMORY ERROR.

DIM A$(100,100) is OK so we're going to use ASC() and CHR$ a lot.

First try failed because accessing memory is slower the further you are in the array, and I missed starts of lines sent via serial. Didn't want to do multiple runs to find out minimal safe delay.

Second try failed : I dumped the contents to floppy using lingest.basic and ascii-xfr with a 5s inter-line delay. Then tried to OPEN and READ the file from BASIC, but things got REAL slow (1 char every 10s), probably due to memory usage.

Third try, reading line by line and splitting into two-dimensional TREE$ array during reading, got too slow after a few lines too.

Fourth try is one more loop, first reading all data, not building a bidimensional array but instead making use of MID$, then iterating twice on that (from top-left, then from bottom-right), then one last time to count visible trees. It failed with an OUT OF MEMORY ERROR.

Figured out about INTEGER variables, DIM TREE%(100,100) for example. Back to reading char by char, but this time reading everything first THEN doing the job. Less elegant, but this one worked in a reasonable timeframe (2 hours for the beautiful O(4n²) algorithm of part 1).

In one reddit thread the author says "I have between 30 and 35kB of memory available." (I think 30kb available is way too low, but surely if the system has the basic 128kb, then the remaining user memory shouldn't be much)

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Advents of Code (programming challenges) - pier4r - 12-10-2022 11:38 AM



User(s) browsing this thread: 5 Guest(s)