In case anyone cares, I've decided to scrap my current brute force logic approach to this process, and go with a rules-based one instead. It will take a really long time for me to code it, though, so in the meantime I've been using a version of the army to keep my main character healed.
I can do individual puzzles faster that I can code a solution, but it makes me sad that a prime scripting opportunity is being lost...perhaps if someone else wants to take it on, I can provide my work thus far.