Scan through the line and break it into segments with counts(| will be segment breaks):
count: 1 1 1 3 3 4 1 2 2 1 4 4 1
segment: 1 2 3 4 5 6 7 8 9 10 11 12 13
b|r|b|rrr|bbb|rrrrr|b|rr|bb|r|bbbb|rrrr|b
now scan through counts with 2 neighbors with the largest counts.
in this case segment 11 and 12
I don't have free pascal installed at the moment to write the code for you.
Let me know if you need more help. Hopefully this will get you on your way.
Bookmarks