W = Right; H = Bottom; size = max(W,H); for(y=1; y<=size; y++){ for(x=y+1; x<=size; x++){ temp = str([x,y]); [x,y] = str([y,x]); [y,x] = str(temp); } } Right = H + 1; Bottom = W + 1;