s='abcb'

d=0;
while ~all(diag(s==rot90(s),d++))
   p=[s fliplr(s(1:d))];
end
p
   
