Challenge
Given an input string X
, determine if X
can be obtained from reshaping a strict prefix of itself (a prefix that is not X
itself).
Reshaping a string to a length N
means repeating the string as many times as needed and then taking the first N
characters of it.
Examples:
The string "abba"
returns Truthy becacause "abb"
can be reshaped to length 4 to obtain "abba"
.
The string "acc" returns Falsy becacause none of its strict prefixes ("a"
, "ac"
) can be reshaped to obtain "acc"
.
(Outputs must be consistent)
Test cases:
AA => 1
ABAba => 0
!@#$%&()_+! => 1
AAc => 0
ababababba => 1
abcdeabc => 1
abacabec => 0
@|#|#|@#|@||@#@||@|#| => 1
10101101101010110101011101111011110110110101101101010110010101101101010110 => 1
17436912791279205786716328174301174187417348216070707180471896347218574617954278517034215720138543912791279205786716328174301174187417348216070707180471896347218574617954278517034215720286716328174301174187417348216070707180471896347218574617954278517034219127912792057867163281743011741874173482160707071804718963472185746179542785170342157205720475941259275912791279205786716328174301174187417348216070707180471896347218574617954278517034215720475941252867163281743011741874173482160707071804718963472185746179542785170342157204759412517436912791279205786716328174301174187417348216070707180471896347218574617954278517034215720138543912791279205786716328174301174187417348216070707180471896347218574617954278517034215720286716328174301174187417348216070707180471896347218574617954278517034219127912792057867163281743011741874173482160707071804718963472185746179542785170342157205720475941259275912791279205786716328174301174187417348216070707180471896347218574617954278517034215720475941252867163 => 1
0
for false, and non-zero for true? \$\endgroup\$