Perfect Palindromes

Brachylog, 7 bytes

~cL↔ᵐLl

Try it online!

Explanation

~cL          Deconcatenate the input into L
  L↔ᵐL       Reversing all elements of L results in L
     Ll      Output = length(L)

Jelly, 13 12 11 bytes

ŒṖLÞŒḂ€P$ÐfḢL
ŒṖLÞṚ€⁼$ÐfḢL
ŒṖṚ€⁼$ÐfL€Ṃ
ŒṖ            obtain partitions
      Ðf      filter for partitions which
  Ṛ€              after reversing each subpartition
    ⁼             is equal to the partition
        L€    length of each successful partition
          Ṃ   minimum

Try it online!

Specs

  • Input: "ababacab" (as argument)
  • Output: 2

Pyth, 9 bytes

lh_I#I#./

Test suite

This forms all partitions of the input, from shortest to longest. Then, it filters those partitions on invariance under filtering the elements on invariance under reversal. Finally, we take the first element of the filtered list of partitions, and return its length.

To explain that complicated step, let's start with invariance under reversal: _I. That checks whether its input is a palindrome, because it checks whether reversing changes the value.

Next, filtering for palindromicity: _I#. This will keep only the palindromic elements of the list.

Next, we check for invariance under filtering for palindromicity: _I#I. This is truthy if and only if all of the elements of the list are palindromes.

Finally, we filter for lists where all of the elements of the list are palindromes: _I#I#.