I think all you need to do is to sort the words descending by length before you run through your loop. See my variation below which is very similar to yours Re^2: Challenge: 8 Letters, Most Words.
The reason is that a longer word will never be added to the stack of a shorter word, so you do not need to check that.
In reply to Re^4: Challenge: 8 Letters, Most Words
by hdb
in thread Challenge: 8 Letters, Most Words
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |