Guest User

Untitled

a guest
May 27th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #Enumerating Gene Orders (Print Permutations)
  2. def perm(n):
  3. #create original list in numerical order
  4. original = [];
  5. i = 1;
  6. while i <= n:
  7. original.append(i);
  8. i+=1;
  9. #use itertools to find all combinations of list
  10. import itertools;
  11. res = list(itertools.permutations(original));
  12. #format answer
  13. print len(res);
  14. j = 0;
  15. k = 1;
  16. perm = ""
  17. while j < len(res):
  18. if j == k:
  19. print perm;
  20. k+=1;
  21. perm = "";
  22. for item in res[j]:
  23. perm = perm + str(item)+ " ";
  24.  
  25. j+=1;
  26. print perm;
  27. perm(3);
Add Comment
Please, Sign In to add comment