Added a permutation algorithm