I won't include the code for this one, but I will show the output of each loop on Examples 0 through 4:
i:0 TOPC ODER. Sorted middle: COPT. String: COPTODER. Best: COPTODER i:1 T OPCO DER. Sorted middle: COOP. String: TCOOPDER. Best: COPTODER i:2 TO PCOD ER. Sorted middle: CDOP. String: TOCDOPER. Best: COPTODER i:3 TOP CODE R. Sorted middle: CDEO. String: TOPCDEOR. Best: COPTODER i:4 TOPC ODER . Sorted middle: DEOR. String: TOPCDEOR. Best: COPTODER COPTODER
i:0 ESP RIT. Sorted middle: EPS. String: EPSRIT. Best: EPSRIT i:1 E SPR IT. Sorted middle: PRS. String: EPRSIT. Best: EPRSIT i:2 ES PRI T. Sorted middle: IPR. String: ESIPRT. Best: EPRSIT i:3 ESP RIT . Sorted middle: IRT. String: ESPIRT. Best: EPRSIT EPRSIT
i:0 AA AAAAAAA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:1 A AA AAAAAA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:2 AA AA AAAAA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:3 AAA AA AAAA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:4 AAAA AA AAA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:5 AAAAA AA AA. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:6 AAAAAA AA A. Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA i:7 AAAAAAA AA . Sorted middle: AA. String: AAAAAAAAA. Best: AAAAAAAAA AAAAAAAAA
i:0 ABRAC ADABRA. Sorted middle: AABCR. String: AABCRADABRA. Best: AABCRADABRA i:1 A BRACA DABRA. Sorted middle: AABCR. String: AAABCRDABRA. Best: AAABCRDABRA i:2 AB RACAD ABRA. Sorted middle: AACDR. String: ABAACDRABRA. Best: AAABCRDABRA i:3 ABR ACADA BRA. Sorted middle: AAACD. String: ABRAAACDBRA. Best: AAABCRDABRA i:4 ABRA CADAB RA. Sorted middle: AABCD. String: ABRAAABCDRA. Best: AAABCRDABRA i:5 ABRAC ADABR A. Sorted middle: AABDR. String: ABRACAABDRA. Best: AAABCRDABRA i:6 ABRACA DABRA . Sorted middle: AABDR. String: ABRACAAABDR. Best: AAABCRDABRA AAABCRDABRA
i:0 BAZING A. Sorted middle: ABGINZ. String: ABGINZA. Best: ABGINZA i:1 B AZINGA . Sorted middle: AAGINZ. String: BAAGINZ. Best: ABGINZA ABGINZA