在此挑战中,将为您提供一个文本块,并且您需要对文本进行反射。
输入:
- 要反映的字符串。文本不能作为其元素为文本行的数组提供。例如,
"ab\ncd"
并且['a','b','\n','c','d']
是允许的,但['ab','cd']
还是[['a','b'],['c','d']]
没有。您可以假定所有行都具有相同数量的字符(在需要时用空格填充)。 - 一个布尔值,其中
True
指示Y反射并False
指示X反射
这两个输入可以任何顺序传递。
输出:
反映的字符串。字符不会改变,只会改变位置。生成的图像块应与左上角对齐(第一行和第一列必须分别包含非空格字符)。允许尾随空格(在任何行上)。
测试用例:
False
o /
--|/
|
/ \
/ o
/|--
|
\ /
True
o /
--|/
|
/ \
/ \
|
--|/
o /
True
text
text
False
text
txet
True
P
P
C
G
G
C
P
P
False
P
P
C
G
P
P
C
G
True
abcde
fghij
kl mn
opqrs
tuvwx
tuvwx
opqrs
kl mn
fghij
abcde
这是一个代码高尔夫,所以用您喜欢的语言回答最短!
\n
I,那么我会说这不是字符串表示形式。
1
和0
)还是必须使用True
和False
?