Swap encoding iteration count
C++ (gcc), 3.809 seconds

Compile with g++ -O3 -std=c++14.
As requested by the OP, the testcases were included in the source.
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;

constexpr int TESTCASES_NUM = 9;
constexpr char *TESTCASES[TESTCASES_NUM] = {"124351141512412435325", "Write a fast-growing assembly function", "And I'm now heading to the elevator", "I'm in the now infamous elevator", "1549827632458914598012734", "i was always mediocre at golfing", "tho, i like some code challenges", "I am once again in an elevator", "A person with mannerism of cat"};

int solve(char *s, int n) {
    int ans = 0;
    int i, j;
    char *p, *q, b;
    char s0[n];
    memcpy(s0, s, n);
    do {
        for(i = 0; i &lt; n; ++i) {
            for(j = i + 1; j &lt; n; ++j) {
                if(s[i] == s[j]) {
                    for(p = s + i + 1, q = s + j - 1; p &lt; q; ++p, --q) {
                        b = *p;
                        *p = *q;
                        *q = b;
                    }
                    break;
                }
            }
        }
        ++ans;
    } while (memcmp(s0, s, n));
    return ans;
}

int main(int argc, char **argv) {
    for(int t = 0; t &lt; TESTCASES_NUM; ++t) {
        char* s = TESTCASES[t];
        int  n = strlen(s);
       &#32;
        int count[300];
        memset(count, 0, sizeof(count));
        for(int i = 0; i &lt; n; ++i) {
            ++count[s[i]];
        }
        char z[n];
        int m = 0;
        for(int i = 0; i &lt; n; ++i) {
            if(count[s[i]] == 1) {
                if(i &gt; 1 and count[s[i - 1]] == 1 and count[s[i - 2]] == 1) {
                    continue;
                }
            }
            if(i &gt; 1 and s[i] == s[i - 2] and count[s[i - 1]] == 1) {
                --m;
                continue;
            }
            if(m == 0 and count[s[i]] == 0) {
                continue;
            }
            z[m++] = s[i];
        }
        while(m &gt; 1 and count[z[m - 1]] == 1) {
            --m;
        }
       &#32;
        printf("%d\n", solve(z, m));
    }
}

Try it online!
The naive implementation, with a couple of preprocessing optimizations.
Say that a character is unique if it occurs exactly once in the input string.

If there are more than 2 consecutive unique characters, we can remove some of them until there are exactly 2 consecutive ones.
We can remove every prefix or suffix consisting entirely of unique characters.
We can make substitutions aba -&gt; a whenever b is unique (thanks to kops for the suggestion!).