Peter placed no. 1 in the steps competition. Here’s an example of part 1:
And the corresponding program, only the rules actually used:
HEADS AABBA
START ***** MOVE0 ***** SRLSU
MOVE0 ABAB* MOVE1 _ba_* RRLLS
MOVE1 bBAa* MOVE2 @ba@* RRLLS
MOVE2 baba* STOP _**_* RRLLS
Use a step to spread the heads. Then use 2×2 heads to read new and previous information. With this string, ABBAAB, the first time this is AB-AB. Delete the outer characters and replace the inner characters with lower case copies. Next time it’s bB-Aa. As bB and Aa represent pairs, 2 @’s are written. Again, the inner characters are changed to lower case. In the next step we get ba-ba, actually the same ba seen twice. Write nothing, delete the characters, stop.
A slightly longer example, ABBABBABBB.
And the program:
HEADS AABBA
START ***** MOVE0 ***** SRLSU
MOVE0 ABBB* MOVE1 _bb@* RRLLS
MOVE1 bBBb* MOVE2 @bb@* RRLLS
MOVE2 bAAb* MOVE3 _aa_* RRLLS
MOVE3 aBBb* MOVE4 _bb@* RRLLS
MOVE4 bbbb* STOP @**_* RRLLS
Apparently there’s a set of rules for each step. Yeah, from what I can tell, the MOVE1 group is almost exactly a duplicate of the MOVE0 group etc. So, this program was quick and easy to write, but could easily have been shorter. However! Right now we’re counting steps, and then it doesn’t matter.
For part 2, more than 1 string of characters is possible.
With 1 string, the program seems to be the same as before. With 2 strings, there are 2×4 heads, and the strings are still processed from both ends at the same time. But with 3-5 strings…
The 4 heads at the end of the strings are simply left there, useless.
The program for case 30:
HEADS AAADDABBCC
START A**B****** PREPAB _**_****** RDDRURLDLU
PREPAB B_*B*!BBAA MOVE_BBBA *@**_**_*_ RRSRRRLLLL
MOVE_BBBA A**B*!A*B* MOVE_ABAB a@*b_*a_b_ RRSRRRLLLL
MOVE_ABAB B**B*!B*A* MOVE_BBBA b@*b_*b_a_ RRSRRRLLLL
MOVE_BBBA B**B*!B*B* MOVE_BBBB b@*b@*b@b_ RRSRRRLLLL
MOVE_BBBB A**A*!B*B* MOVE_AABB a_*a_*b@b@ RRSRRRLLLL
MOVE_AABB B**A*!B*A* MOVE_BABA b@*a_*b@a_ RRSRRRLLLL
MOVE_BABA _a**b***** STOP *_**_***** SSSSSSSSSS
The 1st rule spreads the heads a little. A and B are deleted, but remembered in the state name. The 2nd rule encounters a blank space, and this must just have been created by the 1st rule. So we move into 2 string mode.
The program for case 50:
HEADS AAADDABBCC
START A**B****** PREPAB _**_****** RDDRURLDLU
PREPAB *A**A!**** PREPAAAB *_**_***** SRDSRRSSSS
PREPAAAB AB_BB***** MOVEABBB @_*@_***** RRRRRRSSSS
MOVEABBB BB*BB!**** MOVEBBBB _@*@@***** RRRRRRSSSS
MOVEABBB BB*BB!**** MOVEBBBB _@*@@***** RRRRRRSSSS
MOVEBBBB AB*BB!**** MOVEABBB _@*@@***** RRRRRRSSSS
MOVEABBB BA*AA!**** MOVEBAAA __*__***** RRRRRRSSSS
MOVEBAAA BB*AB!**** MOVEBBBA @_*@_***** RRRRRRSSSS
MOVEBBBA BB*AB!**** MOVEBBBA @@*@@***** RRRRRRSSSS
MOVEBBBA BA*BA!**** MOVEBAAB @_*__***** RRRRRRSSSS
MOVEBAAB AB*BB!**** MOVEABBB __*@_***** RRRRRRSSSS
MOVEABBB BB*AB!**** MOVEBBBA _@*_@***** RRRRRRSSSS
MOVEBBBA AB*BB!**** MOVEABBB _@*_@***** RRRRRRSSSS
MOVEABBB AA*AA!**** MOVEAAAA @_*__***** RRRRRRSSSS
MOVEAAAA AB*BB!**** MOVEABBB @_*__***** RRRRRRSSSS
MOVEABBB BB*AB!**** MOVEBBBA _@*_@***** RRRRRRSSSS
MOVEBBBA AB*BB!**** MOVEABBB _@*_@***** RRRRRRSSSS
MOVEABBB BB*AB!**** MOVEBBBA _@*_@***** RRRRRRSSSS
MOVEBBBA BA*AA_**** STOP @_*@_***** RRRRRRSSSS
PREPAB does not see a blank space in front of head 2, so we go a different path.
Finally, for part 3, pairs are counted both horizontally and vertically.
Apart from a few things in the beginning to detect the number of strings, this feels very familiar. Once we’re set, 4 heads look at the situation and react accordingly. Extra @’s can be written in front of the strings.
Code
.