john,
In some ways what you are asking for is less mathematics and more string handling. I am curious why you may think getting this result would be of use to you? I am confident that it can be done but expect the answer to take some effort to write, so I won’t jump into it without a little more confidence.
The typical algorithm would be to count occurrences and reset the count on change eg from a to b, b to a. to detect a change you need to store the last value to compare.
- the new %if statements within a list widget may be helpful.
- perhaps you could generate substrings of a and b and then test length[] or split and count.
- the list widget now has the counter parameter
post script
the new let and multi-value variables in the 5.4.0 prerelease may be of use here.
also depending on the nature of your output you could use the contains operator to test for different sized strings ‘aaaa’ ‘aaa’ etc…