Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. list1 = [0, 1, 2, 3]
  2. x = 3
  3.  
  4. all_permutations = []
  5.  
  6. print(list1)
  7.  
  8. while len(all_permutations) != 23:
  9. x -= 1
  10. list1[x], list1[x+1] = list1[x+1], list1[x]
  11. all_permutations.append(list1[:])
  12.  
  13.  
  14. if x == 0:
  15. list1[2], list1[3] = list1[3], list1[2]
  16. all_permutations.append(list1[:]) < < < < < < < I forgot to add this line
  17.  
  18. while x != 3:
  19. if len(all_permutations) == 23:
  20. break
  21.  
  22. else:
  23. pass
  24. x += 1
  25. list1[x-1], list1[x] = list1[x], list1[x-1]
  26. all_permutations.append(list1[:])
  27.  
  28.  
  29. list1[0], list1[1] = list1[1], list1[0]
  30. all_permutations.append(list1[:])
  31.  
  32.  
  33. else:
  34. continue
  35.  
  36.  
  37.  
  38. for perm in all_permutations:
  39. print(perm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement