Flip Game
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.
Write a function to compute all possible states of the string after one valid move.
A solution that is almost a brute-force approach is to simply check for instances of “++” in the string and if found, replace with “—” and return. The key here is to ensure that we replace back the “++” for the next iteration namely in the case of three consecutive +’s. The below solution implements the described approach.