The task
In this challenge, your task is to determine whether some string occurs as a substring of a given string both surrounded by another string and reversed.
Your input is a non-empty string S of lowercase ASCII letters. If there exist non-empty strings A and B such that the concatenation ABA and the reversal rev(B) are both contiguous substrings of S, then your output shall be a truthy value. Otherwise, your output shall be a falsy value. The two substrings may occur in any order, and they can even overlap. However, it can be shown that in all truthy cases, you can either find non-overlapping substrings or a solution where B is a palindrome.
Example
Consider the input string S = zyxuxyzxuyx
.
We choose A = xu
and B = xyz
, and then we can find the following substrings:
S = zyxuxyzxuyx
ABA = xuxyzxu
rev(B) = zyx
The choice A = x
and B = u
would also be valid.
The correct output in this case is truthy.
Rules and scoring
You can write a full program or a function. Standard loopholes are disallowed. The lowest byte count wins.
Test cases
Truthy
sds
aaxyxaa
aaxyaaayx
hgygjgyygj
zyxuxyzxuyx
cgagciicgxcciac
iecgiieagcigaci
oilonnsilasionloiaammialn
abbccdeeaabccddbaacdbbaccdbaaeeccddb
Falsy
a
aaxyaa
jjygjhhyghj
abcaabbccaabca
egaacxiagxcaigx
lnsiiosilnmosaioollnoailm
cabbccabdcaddccabbddcaabbdcaddccaadcabbccaabbcadcc
Fun fact
One can construct arbitrarily long falsy strings using four distinct letters, but not using three letters. The fourth falsy test case is the longest possible.
abcaabbccaabcaa
is still falsy with three distinct letters. \$\endgroup\$A = caa
andB = b
, and look at the end of the string. \$\endgroup\$