permutations function

Generate permutations of dimensions to find optimal no of batches