Crappy way of processing all permutations without blowing memory