I am looking to define a Turing machine which takes in a tape of $2n$ $1$'s surrounded by infinite $0$'s e.g., $...0000111111110000...$ and has an end configuration of half of those $1$'s e.g., $...0001111000...$.
Here are my thoughts: I am thinking that my Turing machine could "count" the number of $1$s by replacing every second $1$ with a sentinel value and then keeping a tally of the parity to the right of all of the $1$'s. Then we could go back to the beginning of the (now cleared) tape and write that many $1$'s. Is this a correct approach? Any tips for implementation?
Your idea sounds good, have you tried implementing it? I'd recommend you give that a try before you read on, it's like a fun little programming exercise that helps improve your understanding of Turing machines, no matter if you get it right or wrong the first try. This site allows you to write a TM and check whether it does what you expect it to do.
Now, here's my solution.
Think of the task divided into three steps:
Note: This solution doesn't work if $n=0$, but that can be fixed quite easily. Do you see how?