An palindrome is a word that is its own reverse.
Now there are some words that might look like palindromes but are not. For example consider the word sheesh
, sheesh
is not a palindrome because its reverse is hseehs
which is different, however if we consider sh
to be a single letter, then it's reverse is sheesh
. This kind of word we will call a semi-palindrome.
Specifically a word is a semi-palindrome if we can split up the word in to some number of chunks such that when the order of the chunks are reversed the original word is formed. (For sheesh
those chunks are sh e e sh
) We will also require no chunk contains letters from both halves of the word (otherwise every word would be a semi-palindrome). For example rear
is not a semi-palindrome because r ea r
has a chunk (ea
) that contains letters from both sides of the original word. We consider the central character in an odd length word to be on neither side of the word, thus for words with odd length the center character must always be in it's own chunk.
Your task will be to take a list of positive integers and determine if they are a semi-palindrome. Your code should output two consistent unequal values, one if the input is a semi-palindrome and the other otherwise. However the byte sequence of your code must be a semi-palindrome itself.
Answers will be scored in bytes with fewer bytes being better.
Test-cases
[] -> True
[1] -> True
[2,1,2] -> True
[3,4,2,2,3,4] -> True
[3,5,1,3,5] -> True
[1,2,3,1] -> False
[1,2,3,3,4,1] -> False
[11,44,1,1] -> False
[1,3,2,4,1,2,3] -> False
Program to generate more testcases.
borrible pointed out that these are similar to generalized Smarandache palindromes. So if you want to do some further reading that's one place to start.