Given a string of characters as input, without using regular expression or pattern matching, how to get the output, if the characters matches aaa should output 1 and if the characters matches aBa should output 2. (Note: Should not re-process characters so as to output both “1” and “2” when processing the same input)
So for example:
given 'aaBaBaaaBaaa' it should output 211
given 'aaaBaBaaaaBBaBaBa' it should output 1212
Thanks in advance.