In this challenge, you will be given a text block, and you need to perform reflection on the text.
- A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example,
['a','b','\n','c','d']are allowed, but
[['a','b'],['c','d']]are not. You can assume that all of the lines have the same number of characters (padded with whitespace where needed).
- A boolean where
Trueindicates Y reflection and
Falseindicates X reflection
The two inputs can be passed in any order.
The reflected string. The characters do not change, only their position. The resulting image block should be aligned to the top left (the first row and column must each contain a non-whitespace character). Trailing whitespace (on any of the lines) is allowed.
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
This is a code-golf, so answer with the shortest answer in your favorite language!
0) or we must use
\nI would go as far as to say that it's not a string representation. \$\endgroup\$