1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-11-09 13:59:55 +00:00
random-stuff/cyclcm.py
2023-06-19 14:09:54 +01:00

25 lines
529 B
Python

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)