Haskell, 52(削除) 52 (削除ここまで) 44 bytes
f k=[('k=[[" '<$['B'..s])++",s:" "]>>=(['A'..s]>>s:" "s]>>)|s<-['A'..k]]
Returns a list of lines.
f k= -- main function is f, input parameter k
[ |s<-['A'..k]] -- foreachfor each s from ['A'..k]
>>= -- map ('and '<$['B'..s]collect the results in a single string) the function:
(['A'..s]>>) -- replace each element in ['B'['A'..s] with a space
++[ , ] -- and appendover the list, containing
['A'..s]>>s:" " -- (length of ['A'..s])a copiessingle ofspace theto twoget characterthe listindent
s:" " -- s --followed [s,space]by space to get the letter sequence
Edit: @jferard: saved three bytes. Thanks!
Haskell, 52 bytes
f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]
Returns a list of lines.
f k= -- main function is f, input parameter k
[ |s<-['A'..k]] -- foreach s from ['A'..k]
(' '<$['B'..s]) -- replace each element in ['B'..s] with a space
++ -- and append
['A'..s]>>s:" " -- (length of ['A'..s]) copies of the two character list
-- [s,space]
Haskell, (削除) 52 (削除ここまで) 44 bytes
f k=[[" ",s:" "]>>=(['A'..s]>>)|s<-['A'..k]]
Returns a list of lines.
f k= -- main function is f, input parameter k
[ |s<-['A'..k]] -- for each s from ['A'..k]
>>= -- map (and collect the results in a single string) the function:
(['A'..s]>>) -- replace each element in ['A'..s] with
[ , ] -- over the list, containing
" " -- a single space to get the indent
s:" " -- s followed by space to get the letter sequence
Edit: @jferard: saved three bytes. Thanks!
Haskell, 52 bytes
f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]
Returns a list of lines.
f k= -- main function is f, input parameter k
[ |s<-['A'..k]] -- foreach s from ['A'..k]
(' '<$['B'..s]) -- replace each element in ['B'..s] with a space
++ -- and append
['A'..s]>>s:" " -- (length of ['A'..s]) copies of the two character list
-- [s,space]
Haskell, 52 bytes
f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]
Returns a list of lines.
f k= -- main function is f, input parameter k
[ |s<-['A'..k]] -- foreach s from ['A'..k]
(' '<$['B'..s]) -- replace each element in ['B'..s] with a space
++ -- and append
['A'..s]>>s:" " -- (length of ['A'..s]) copies of the two character list
-- [s,space]