Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 145 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 52(削除) 52 (削除ここまで) 44 bytes

f k=[('k=[[" '<$['B'..s])++",s:" "]>>=(['A'..s]>>s:" "s]>>)|s<-['A'..k]]

Returns a list of lines.

Try it online! Try it online!

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.

Try it online!

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.

Try it online!

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!

added 406 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 52 bytes

f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]

Returns a list of lines.

Try it online!

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]]

Try it online!

Haskell, 52 bytes

f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]

Returns a list of lines.

Try it online!

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]
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 52 bytes

f k=[(' '<$['B'..s])++(['A'..s]>>s:" ")|s<-['A'..k]]

Try it online!

AltStyle によって変換されたページ (->オリジナル) /