编码器总是试图把数组压平成枯燥的一维实体,这让我很难过。
你的任务是解开任意字符串,输出一个可爱的城市天景。
考虑一下字符串:aaabbbbbccqrrssstttttttPPw
看起来这样好多了:
tt
tt
bb tt
bb tt
aabb sstt
aabbcc rrssttPP
aabbccqqrrssttPPww(好的,是的,这些字母被复制,以使它看起来更像城市天际线)。
取一个输入字符串,复制匹配字符的每个部分(不一定是字母),并为我创建一个城市!
最短代码字节获胜。
实际上,我认为我已经确定了要求,但我要回答一些问题:
发布于 2017-06-27 11:36:46
γ€DζR»在比挑战更新的版本中,添加了ζ作为.Bø的替代品。
γ€D.BøR»解释:
γ Convert into a list of consecutive equal elements
€D Duplicate each element
.B Squarify; pad each element with spaces so that they are the length of the longest element
ø Transpose
R Reverse (otherwise the city would be upside-down)
» Join by newlines发布于 2017-06-27 11:36:59
发布于 2017-06-27 12:04:15
qe`::*:__:,:e>f{Se[}zN*解释:
qe`::*:__:,:e>f{Se[}zN* Accepts (multi-line?) input
q Take all input
e`::* Split into groups of equal elements
:_ Duplicate each
_:,:e> Push maximal length without popping
f{Se[} Left-pad each to that length with space strings (NOT space chars, although not a problem here)
z Zip
N* Join with newlineshttps://codegolf.stackexchange.com/questions/128611
复制相似问题