Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list1 = [0, 1, 2, 3]
- x = 3
- all_permutations = []
- print(list1)
- while len(all_permutations) != 23:
- x -= 1
- list1[x], list1[x+1] = list1[x+1], list1[x]
- all_permutations.append(list1[:])
- if x == 0:
- list1[2], list1[3] = list1[3], list1[2]
- all_permutations.append(list1[:]) < < < < < < < I forgot to add this line
- while x != 3:
- if len(all_permutations) == 23:
- break
- else:
- pass
- x += 1
- list1[x-1], list1[x] = list1[x], list1[x-1]
- all_permutations.append(list1[:])
- list1[0], list1[1] = list1[1], list1[0]
- all_permutations.append(list1[:])
- else:
- continue
- for perm in all_permutations:
- print(perm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement