in reply to Tricky math problem ...
Why are you running this puzzle from top left to bottom right? Why not bottom right to top left? If the star has to be in the top left of the box then the second approach would make more sense. Am I right? It would simplify the code slightly. Once no remaining stars then the code would split the remainder according to a separate algorithm. This second algorithm would apply from top left to bottom right. It would then be applied to all areas where there is no box, in the same way. This second algorithm would be held in a subroutine. Does my thinking seem correct?