Took about an hour and change but got there for p1!
2. Batch Macro to run the same initial point
3. Iterative macro to check each step and overwrite existing file with updated point once stable
Well, I set a personal record for number of macro iterations... 1.8 million (before it failed due to a memory error). Needless to say, there was a better way to solve part 2 than brute force iteration 😂
Part 2: I started by tracking the grains of sand individually, brute force iteration. After 600,000, this was all the progress it had made:
after 1.8 million iterations and 10 hours, it had only gathered 15,000 grains of sand. This is ~50% of the total grains of sand. I decided I needed a new approach.
Part 2, new approach: start with the entire sand pyramid as if there were no rocks. Then, subtract out all the grains of sand blocked vertically by the rocks. Add back sand that shifted left and right. Runs in 10 seconds.
Visual representation of part 2 answer:
In the true spirit of Red-Green-Refactor - my solution to day 14 is awful - and it takes 18 hrs and 43 mins to solve part 2 on a 32 thread 2nd gen ThreadRipper with 64GB of RAM. If this means nothing to you - then the summary is that my solution is terrible and would take a few days to complete on a regular laptop.
however - it completed - any updates to this can only get better :-)
it makes a big difference - the stripped down version looks like this:
Compared to the version that has all the cells that are surrounded (and not going anywhere) that looks like this
macro:
macro:
1. check all blank position from the triangle, from top to bottom. line by line. (i.e., by Y level)
2. check neighbors from 3 directions above it (left up, up, right up) for each position.
3. if any neighbors got "Sand" then it will be "Sand".
hence, it will only take loop based on max_y.
hello @clmc9601 can you share me the workflow visualize part. or link for config it?
I tried to build one, but it not working, it still okay in map tool's preview but output only show as block.
Had to refactor part 2
Poorly laid out macro:
Sure, @PangHC, workflow attached. I'm also posting all of my solutions here on GitHub.