Function to do level permutations according to Weng's algorithm without using a stored list of all permutations
Useful links