| CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 06:57:07 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=53c00d169567d72e024c5827e52cb137e3204c65fafc9f7fad260c4e68abb25ba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22PpdhpZsaeSABDAKcDPmhG5-L0F4WmPPY%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d4b3865ee9b277-BLR
OEIS A280319 (Steinhaus–Johnson–Trotter algorithm) - Pastebin.com
SHARE
TWEET
OEIS A280319 (Steinhaus–Johnson–Trotter algorithm)
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://oeis.org/A280319
- # listing the permutations generated by Steinhaus–Johnson–Trotter algorithm as their reverse colexicographic index numbers
- # s_permutations comes from https://rosettacode.org/wiki/Permutations_by_swapping#Python:_recursive
- from itertools import permutations
- from bidict import bidict
- from math import factorial
- m = 7
- sjt_numbers = []
- for n in range(1, m+1):
- # generate n-element permutations in reverse colexicographic order
- perms_iter = permutations(list(range(n)))
- perms_revcolex_bidict = bidict()
- for i, perm in enumerate(perms_iter):
- perms_revcolex_bidict[factorial(n)-1-i] = tuple(perm[::-1]) # create reverse colexicographic order
- # generate n-element permutations in Steinhaus–Johnson–Trotter order
- def s_permutations(seq):
- def s_perm(seq):
- if not seq:
- return [[]]
- else:
- new_items = []
- for i, item in enumerate(s_perm(seq[:-1])):
- if i % 2:
- # step up
- new_items += [item[:i] + seq[-1:] + item[i:]
- for i in range(len(item) + 1)]
- else:
- # step down
- new_items += [item[:i] + seq[-1:] + item[i:]
- for i in range(len(item), -1, -1)]
- return new_items
- return [tuple(item) for item in s_perm(seq)]
- perms_sjt = s_permutations(list(range(n)))
- # assign rev colex index numbers to permutations
- for i in range(factorial(n)):
- perm = perms_sjt[i]
- sjt_number = perms_revcolex_bidict.inv[perm]
- sjt_numbers.append(sjt_number)
- print(sjt_numbers)
- b_file_text = ''
- for i, e in enumerate(sjt_numbers):
- b_file_text += '%s %s\n' % (i, e)
- b_file = open('b_file', 'w')
- b_file.write(b_file_text)
Advertisement
Add Comment
Please, Sign In to add comment
-
✅⭐ Make huge profits on trading ⭐⭐ E
JavaScript | 26 sec ago | 0.25 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 35 sec ago | 0.25 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ Y
JavaScript | 44 sec ago | 0.25 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ A
JavaScript | 53 sec ago | 0.25 KB
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ L
JavaScript | 1 min ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ H
JavaScript | 1 min ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ 5
JavaScript | 1 min ago | 0.25 KB
-
✅⭐ Make huge profits on trading ⭐⭐ E
JavaScript | 1 min ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand