Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # idx_permu_plus.py
- import math
- def idx_permu(idx, length=8):
- elements = list(range(length))
- result = []
- for i in range(length - 1, -1, -1):
- facto = math.factorial(i)
- pos = idx // facto
- result.append(elements.pop(pos))
- idx %= facto
- return result
- length = 6
- facto = math.factorial(length)
- step = int(facto * 0.99)
- while step > 2:
- while math.gcd(step, facto) != 1:
- step -= 1
- i = 0
- count = 0
- while count < facto:
- result = idx_permu(i, length)
- print(result, step, f'{count + 1}/{facto}')
- i = (i + step) % facto
- count += 1
- step -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement