> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Flip Game Python Solution with Tests

> Tested Python solution for LeetCode 293 with 14 pytest cases. Generate a practice environment with lcpy.

LeetCode 293, [Easy](/catalog/easy). Topics: [String](/catalog/topics/string). [View on LeetCode](https://leetcode.com/problems/flip-game/description/).

Generate this problem as a practice environment: tested reference solution, 14 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 293   # by problem number
lcpy gen -s flip_game   # by problem name
```

## Problem

You are playing a Flip Game with your friend.

You are given a string `currentState` that contains only `'+'` 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.

Return all possible states of the string `currentState` after **one valid move**. You may return the answer in **any order**. If there is no valid move, return an empty list `[]`.

### Examples

```
Input: currentState = "++++"
Output: ["--++","+--+","++--"]
```

```
Input: currentState = "+"
Output: []
```

### Constraints

* `1 <= currentState.length <= 500`
* `currentState[i]` is either `'+'` or `'-'`.

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flip_game/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flip_game/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
class Solution:
    # Time: O(n^2) where n is the string length
    # Space: O(n) excluding the output
    def generate_possible_next_moves(self, current_state: str) -> list[str]:
        results: list[str] = []
        for i in range(len(current_state) - 1):
            if current_state[i : i + 2] == "++":
                results.append(current_state[:i] + "--" + current_state[i + 2 :])
        return results
```

## Complexity

| Time | Space |
| - | - |
| O(n^2) where n is the string length | O(n) excluding the output |

## Tags


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.