Sliding Capitals

Pyth, 31 bytes

Vr_tQ26s.erb%+Nk2+*Nd:GeS,0N+NQ

Try it online. Test suite.

Quick and dirty.


AWK, 160 bytes

{d=-$1
m=25
for(;i<m+$1;i++){f="%"(++d<0?0:d<m?d:m)"s"
c=u=65
l=97
printf f,""
for(j=++E-$1;j<E&&j<26;j++){c=c==u?l:u
if(j<0)continue
printf("%c",j+c)}print""}}

That's about as tight as I can come up with in AWK. Having 3 different prints and a continue really add to the byte-count.


JavaScript (ES6), 130 bytes

n=>[...Array(n+25)].map(_=>[...Array(26)].map(_=>String.fromCharCode(j++<i|i+n<j?32:j+(j-i)%2*32),++i,j=64).join``,i=64-n).join`\n`

Where \n represents the literal newline character. Works by looping over the output rectangle and outputting spaces outside the diagonal while adding 32 to the character code to lower case it in alternate squares. Using replace appears to be 1 byte longer:

n=>[...Array(n+25)].map(_=>' '.repeat(26).replace(/./g,s=>j++<i|i+n<j?s:String.fromCharCode(j+(j-i)%2*32),++i,j=64),i=64-n).join`\n`