I'm working on an assignment in which we are given a single line of

**-**or

**o**characters (12 of them).

A "

**-**" represents an empty hole and a "

**o**" represents a peg-filled hole. Pegs can be removed by jumping over other pegs, but only if they have an empty hole to jump into, like so...

oo- <- the first o can jump over the second, which removes the second, and into the empty hole.

o-o <- neither can jump

-oo <- the second o can jump over the first, which removes the first, and into the empty hole.

It's basically like drafts, but you can only move if you are jumping over another peg, and you can move both left and right.

**I am having problems working this out. I emailed my tutor as we were given no hints on how to accomplish this, and he said that a brute-force search is feasible as the input size is not that great. I then worked on some pseudocode which looked like this:**

I have to find the minimum number of pegs that can be left.

I have to find the minimum number of pegs that can be left.

count = number of o's; for (int i = 0; i < size of the array; i++){ if (token[i] == "-"){ i++; } else if(token[i] == token [i+1]){ if(token[i+2] == "-"){ token[i+2] = "o"; count--; i += 3; } else{ i += 3; } } }

but then realised that this is only going to run UP the line and never down. I am confused at what I should do to rectify this. Has anyone worked on a problem similar to this before? Can they please give me advice or help?

Thank-you!