It’s almost the weekend so here’s a silly puzzle for you. Consider this algorith...
Slava Pestov @slava@mathstodon.xyz
It’s almost the weekend so here’s a silly puzzle for you. Consider this algorithm that takes a string made up of ‘a’ and ‘b’:
1. If the input string does not contain “baaa”, stop.
2. Replace the first occurrence of “baaa” with “aaabba” in the input string.
3. Go back to Step 1.
Example: baabaaa -> baaaaabba -> aaabbaaabba -> aaabaaabbabba -> aaaaaabbabbabba -> Stop
Does this eventually stop on all inputs? If not, what’s an example of a string where this runs forever?