An example of permutation algorithm in Python