We made the levels by hand, writing a script to generate and validate levels is still an interesting math problem I would love to tackle if i had the time, its just very difficult from the limited attempt I made.
Edit: Ah, didn't realize you increased the density of squares on the cube as levels progressed. Very nice.