I have tried to make a Post machine for that all words of the form $a^nb^n$ by the following steps.
- add a marker '#'
- read first 'a'
- read next 'a's and add them
- read first 'b'
- read next 'b's and add them
- read '#' (that we added in the first step)
repeat steps while input tape is not empty
but this algorithm also accepts words of the form $(ab)^n$ e.g abab, ababab I want to make a Post machine that only accepts words of the form $a^nb^n$ How to do that?