Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input("Input 'n'"))
- intlist = []
- i = 1
- while n >= i:
- intlist.append(i)
- i += 1 # I don’t understand why this won’t work if it’s not in ascending order
- total = 1
- for item in range(0, len(intlist), 1):
- total *= intlist[item]
- intset = set([])
- while len(intset) < total:
- intset.add(str(intlist))
- k = l = None
- for i in range(0, len(intlist)-1):
- if intlist[i] < intlist[i+1]:
- k = I # Looking for last occurrence in number set where I is less than it’s neighbor?
- if k == None:
- break
- for i in range(k+1, len(intlist)):
- if intlist[k] < intlist[i]:
- l = I # Doing the same as first for loop? Set to new variable?
- intlist[k], intlist[l] = intlist[l], intlist[k]
- intset.add(str(intlist))
- intlist[k+1:] = intlist[k+1:][::-1] # In particular this line
- intset.add(str(intlist))
- intlist = list(intset)
- print(len(intlist))
- for i in range(0, len(intlist)):
- print(intlist[i].replace('[', '').replace(']', '').replace(',', ''))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement