I have a sequence of characters xxxxxx (with x^k and k > 0) My goal is to transform this sentence into a dutch flag, that is to say :
xxxxx -> RRWWBB xxxx -> RWBB
with R <= W <= B
All solutions that I have found, have a very high complexity. Do you have any hint/clue to help to me build a Turing machine using only one tape and one head/cursor?