# Day 12: Subterranean Sustainability

This is the first problem that I still haven’t an efficient way to solve the second part.

I went with a pretty simple solution for the first part, calculating the next generation by looking up whether each plant is alive or not in the notes. This worked fine for 20 generations.

Scaling this to the second part and it’s 50,000,000,000 generations just isn’t cutting it. After some tests, my code runs 1,000,000 generations in about 7 seconds. 50 billion generations would take me around 97 hours of computing which is doable but not something I want to run.

I skipped the second part for today and will come back to it later when I have more time or when I have an idea to improve my solution. My remaining ideas are to try to parallelize the computing of a generation or use memoization and check if some sections of the plants have been calculated before.

UPDATE: I came back to this problem on December 20th and noticed that at some point the cavern is full and just moves towards the right. So I changed my code to accommodate for this by checking if my state didn’t change from the last iteration and checking the difference in the sum from the last iteration. At this point I saved the number of iterations remaining and simply multiplied that by the difference and added the last sum I saw.