ハスク、24 17バイト
TmoTT' §CȯmLTC3Ow
オンラインでお試しください!
説明
Huskには現在、リストを特定の数のパーツに分割するための組み込み機能がないため、これは驚くほどトリッキーな課題でした。
TmoTT' §CȯmLTC3Ow Implicit input, say s="bbb a cc ddd e"
w Split at spaces: x=["bbb","a","cc","ddd","e"]
C3 Cut into slices of length 3: [["bbb","a","cc"],["ddd","e"]]
T Transpose: [["bbb","ddd"],["a","e"],["cc"]]
ȯmL Map length: [2,2,1]
These are the correct lengths of the columns.
§C O Sort x and split into these lengths: [["a","bbb"],["cc","ddd"],["e"]]
These are the columns of the correct output, without padding.
mo For each column,
T' transpose and pad with spaces: [["ab"," b"," b"],["cd","cd"," d"],["e"]]
T then transpose back: [["a ","bbb"],["cc ","ddd"],["e"]]
T Transpose the whole list: [["a ","cc ","e"],["bbb","ddd"]]
Implicitly join each row by spaces,
join the resulting strings by newlines and print.