1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-11-08 05:29:54 +00:00
random-stuff/cyclcm.py

25 lines
529 B
Python
Raw Normal View History

2023-06-19 13:09:54 +00:00
import math, itertools
count = 0
for permutation in itertools.permutations(range(7)):
perm = [
list(range(7)),
list(permutation)
]
perm = dict(zip(*perm))
vals = set(perm)
print(perm)
cycs = []
while vals:
nxt = vals.pop()
seen = []
while nxt not in seen:
lnxt = nxt
nxt = perm[nxt]
seen.append(lnxt)
cycs.append(seen)
vals -= set(seen)
if math.lcm(*map(len, cycs)) == 4:
count += 1
print(count)