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 Revisions

3 of 3
Commonmark migration

Haskell, (削除) 127 (削除ここまで) 120 bytes

e=[]:e
i#[x]=[]
i#s|t<-foldl(flip$zipWith(:))e$init s,j<-i++last s=(map((j>>" ")++)(init t)++[j++last t]):j#t
f s=s:""#s

Try it online!

Input is a list of lines, e.g. ["DC","AB"] for the second test case, output is a list of lists of lines: [["DC","AB"],[" D","ABC"],["ABCD"]]. Use mapM (putStrLn . unlines) to pretty-print the result.

Edit: Saved 7 bytes by noticing that the shorter transpose I found some while a go comes in handy because it can be modified to reverse each transposed directly.

Laikoni
  • 26.4k
  • 7
  • 54
  • 116

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