<p>Given a string <code>s</code> and an integer <code>k</code>, partition <code>s</code> into <code>k</code><strong><spandata-keyword="substring-nonempty">substrings</span></strong> such that the letter changes needed to make each substring a <strong>semi-palindrome</strong> are minimized.</p>
<p>A <strong>semi-palindrome</strong> is a special type of string that can be divided into <strong><spandata-keyword="palindrome">palindromes</span></strong> based on a repeating pattern. To check if a string is a semi-palindrome:</p>
<ol>
<li>Choose a positive divisor <code>d</code> of the string's length. <code>d</code> can range from <code>1</code> up to, but not including, the string's length. For a string of length <code>1</code>, it does not have a valid divisor as per this definition, since the only divisor is its length, which is not allowed.</li>
<li>For a given divisor <code>d</code>, divide the string into groups where each group contains characters from the string that follow a repeating pattern of length <code>d</code>. Specifically, the first group consists of characters at positions <code>1</code>, <code>1 + d</code>, <code>1 + 2d</code>, and so on; the second group includes characters at positions <code>2</code>, <code>2 + d</code>, <code>2 + 2d</code>, etc.</li>
<li>The string is considered a semi-palindrome if each of these groups forms a palindrome.</li>
</ol>
<p>Consider the string <code>"abcabc"</code>:</p>
<p><strong>Explanation: </strong> Divide <code>s</code> into <code>"ab"</code> and <code>"cac"</code>. <code>"cac"</code> is already semi-palindrome. Change <code>"ab"</code> to <code>"aa"</code>, it becomes semi-palindrome with <code>d = 1</code>.</p>
<p><strong>Explanation: </strong> Divide <code>s</code> into substrings <code>"abc"</code> and <code>"def"</code>. Each needs one change to become semi-palindrome.</p>
<p><strong>Explanation: </strong> Divide <code>s</code> into substrings <code>"aa"</code>, <code>"bb"</code> and <code>"aa"</code>. All are already semi-palindromes.</p>