Created
May 30, 2016 07:32
-
-
Save kyontan/a691f2ac4608580ad167f943df5d233e to your computer and use it in GitHub Desktop.
群のなんか
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply(x, k) | |
ret = [] | |
x.each.with_index{|a, i| ret[i] = k[a-1] } | |
ret | |
end | |
def dim(x) | |
t, i = x, 1 | |
loop do | |
t = apply(t,x) | |
# p i:i, t:t | |
break if t == x | |
i = i+1 | |
end | |
i | |
end | |
def applya(a, x) | |
t = a | |
x.each{|tt| t = apply(t, tt) } | |
t | |
end | |
def applyx(x) | |
t = x.pop | |
applya(t, x) | |
end | |
# [a1,a2].repeated_permutation(2).each{|x| print x if s4 == applyx(x) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment