Something like that?
def rotate a,len,ii=0,jj=0,t=1
t.times do
a = a.map.with_index do |line,i|
line.map.with_index do |e,j|
(ii...(ii+len))===i && (jj...(jj+len))===j ?
a[ii+jj+len-j-1][jj+i-ii] : e
end
end
end
a
end
t = (1..6).map{|i|(1..6).map{|j|j+6*i-6}}
t.each { |i| p i }
rotate(t,3,2,1).each { |i| p i }
rotate(t,6).each { |i| p i }
rotate(t,3,2,1,4).each { |i| p i }
rotate(t,6,0,0,4).each { |i| p i }
rotate(t,2,2,2,3).each { |i| p i }
source
share