More power to you!
|
The power of a permutation is the number of times it must be applied to produce the identity permutation. For example:
p=. 2 0 3 1
] t=. 5#,:p
2 0 3 1
2 0 3 1
2 0 3 1
2 0 3 1
2 0 3 1
{/\t
2 0 3 1
3 2 1 0
1 3 0 2
0 1 2 3
2 0 3 1
p&{ ^: 4 'ABCD'
ABCD
]q=. 10?.10
6 9 1 4 0 2 3 8 7 5
] c=. C. q NB. Cycle representation of q
┌───────┬───┬───────┐
│6 3 4 0│8 7│9 5 2 1│
└───────┴───┴───────┘
] powers=. #&> c NB. Lengths of cycles
4 2 4
*./ powers NB. LCM of powers
4
q&{^:8 'ABCDEFGHIJ' NB. Apply q 4 times
ABCDEFGHIJ
|