Skip to content

Instantly share code, notes, and snippets.

@kyontan
Created May 30, 2016 07:32
Show Gist options
  • Save kyontan/a691f2ac4608580ad167f943df5d233e to your computer and use it in GitHub Desktop.
Save kyontan/a691f2ac4608580ad167f943df5d233e to your computer and use it in GitHub Desktop.
群のなんか
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