In this challenge, your task is to detect (vertical) Skewer Symmetry. This means that one half of the pattern can be produced by mirroring the other half along a vertical axis, and then moving it vertically.
For example, the following pattern has skewer symmetry:
asdf
jkl;fdsa
;lkj
Because if you start from the left half...
asdf
jkl;
...then mirror it along a vertical axis...
fdsa
;lkj
...then move it down by a character (filling the empty rows with spaces)...
fdsa
;lkj
...you get the second half.
Rules:
- You may assume the input is rectangle and has an even number of columns.
- If the pattern itself exhibits reflection symmetry, it is considered skewer symmetry.
- This is strict character by character symmetry, so
[[
is considered symmetrical, but not[]
. - You should output truthy if the input has skewer symmetry, falsy otherwise.
- Default I/O rules apply, standard loopholes are banned.
Test Cases
Truthy cases:
asdf
jkl;fdsa
;lkj
asdffdsa
[
[
ba
abdc
cd
Falsy cases:
[
]
ab
ba
aa
a
a
a a
b b
ab
b
a
["abfe","cdhg","efba","ghdc"]
. i don't know what the result should be. \$\endgroup\$["ab ", " b ", " a"]
(where the columns are symmetric with the spaces stripped, but not with spaces present) \$\endgroup\$["ab", "ba"]
test case, result should be falsy (it’s a symmetry+rotation, while skew symmetry is only symmetry+translation). \$\endgroup\$["ab..", "..b.", "...a"]
, with the dots replaced with spaces. \$\endgroup\$[" ba","abdc","cd "]
-> truthy (left part is moved downwards). May we assume, that the input contains only printable ASCII (' '
(space) to'~'
)? \$\endgroup\$