Given is a row of at most 30 stones which can either be black or white. No gaps are allowed at the start of the game, but there can be less than 30 stones. The goal is to remove all the stones. Only black stones can be removed, if a stone is removed, its neighbours change colours. If the stone removed was in the middle, this produces a gap that can't be filled any more; the neighbours of that stone are not considered neighbours after the stone is removed.
Now, I have created a program that solves this game using brute force. I have concluded that the game is only solvable if there are any black stones at all (obviously) and if the number of black stones is odd. Also, if the number of black stones is odd, the game can be solved by recursively removing the first black stone of the row.
My problem is I can't prove this condition that the number of black stones must be odd and that removing the first stone will solve the game. How can I correctly prove this algorithm?
I already tried to use induction, but I'm stuck:
Row(a,b) = a*black + b*white
RemoveFirstBlack(Row(1, b)) = RemoveFirstBlack(black + b*white) = 0 (if a=1 or n = 0 where a=2n+1 and n an integer)
Assume RemoveFirstBlack(Row(k*a, b)) = RemoveFirstBlack(k*a*black + b*white) = 0 with k = 2p + 1 and p an integer.
RemoveFirstBlack(Row((k+1)*a, b)) = RemoveFirstBlack((k+1)*a*black + b*white) = RemoveFirstBlack((2(p+1)(2n+1))*black + b*white) = RemoveFirstBlack(2(p+1)*a*black + b*white) = 0?
Thanks in advance for any pointers at all!