Post Reply 
Advents of Code (programming challenges)
12-26-2022, 07:46 PM
Post: #27
RE: Advents of Code (programming challenges)
Thank you, and in fact I did it.

The input was stored as array of complex numbers. Why an array? Because it is quick to populate/edit compared to a long list (this is something I want to exploit in an "array processing" thread, that then never got momentum). Especially if the dimension at first is predetermined.

Thus I first allocate an array of dummy complex numbers.
Then I go through the input and I say the (x,y) as complex numbers (one can see the suggestion also by the 50g AUR where complex numbers are used as x,y of a picture)

Then I trim the array with the actual numbers.
While I read the input, I also noticed the minX and maxX (one can see those as global values). So that I can trim the map starting from the first X that has actually rock in it. The Y instead is from 0 (actually 1) to the maxY since one does not know where the sand will accumulate (surely there will be pesky crannies).

Then I go through this array and I start to build the matrix given the dimensions above. And the map is the hard part to store. As the array of input complex numbers will be discarded after building the map, is the map that has the larger weight (as far as I could see) and I couldn't keep it as global variable, because as soon as it went to the stack too, there was no space left (where I was expecting only a reference rather than a copy).

Moving the storage to port 1 - while recalling it every now and then to the stack - helped. Now I need to find time to complete P1 and P2.
Then let's see if day15 is doable. Another approach could be that I skip to the less difficult days first (from around the 20th) and then I go back to the hard ones.

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-26-2022 07:46 PM



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