Moves in squared strings (I)
Last updated
Was this helpful?
Last updated
Was this helpful?
This kata is the first of a sequence of four about "Squared Strings".
You are given a string of n
lines, each substring being n
characters long: For example:
s = "abcd\nefgh\nijkl\nmnop"
We will study some transformations of this square of strings.
Vertical mirror:
vert_mirror (or vertMirror or vert-mirror)
Horizontal mirror:
hor_mirror (or horMirror or hor-mirror)
or printed:
Write these two functions
and
high-order function oper(fct, s)
where
fct is the function of one variable f to apply to the string s
(fct will be one of vertMirror, horMirror
)
The form of the parameter fct
in oper changes according to the language. You can see each form according to the language in "Sample Tests".
The input strings are separated by ,
instead of \n
. The output strings should be separated by \r
instead of \n
. See "Sample Tests".
Forthcoming katas will study other transformations.