Disclaimer: This is an exact copy of a post I made on Stack Overflow. A user brought my attention to CS Stack overflow. Since it is actually better suited here I thought I might ask it here as well. If answered I would link from SO to here of course.
Using a cellular automata, I would like to take a tape as an input containing I‘s is surrounded by an arbitrary amount of O‘s and square the number of I‘s: O O O O I I O O O -> O O O O I I I I O O O
Stephen Wolfram explains how a cellular automata can square the number of N inputs like this:
I have some problems with this. On one hand I don’t understand what p or eg. 7-p is supposed to be. Neither do I understand what the input state was. 1? 6? On the other hand I see from the images which correspond to the rules, that Wolframs output has some remaining helper symbols:
O O O O I I O O O -> O O O O X X I I I I O O O
So far my approach has been to handle it like a string rewriting system. I added markers at both ends and tried to move a courser back and forth to square the unitary number:
( ,O,I) ==> L (I,O,O) ==> R (L,I,I) ==> > (>,I,I) ==> > ...
I managed to get a pass from left to right and copy one value over the R, but this took me already more than 20 of these lines. This looks way worse than Wolfram’s solution.