Ctrl K

The Vowel Cutting Game

Medium
Two players take turns on a string text; the first player moves first. - On their turn, the first player cuts out any non-empty contiguous piece that contains an **odd** number of vowels. - The second player cuts out any non-empty contiguous piece that contains an **even** number of vowels (zero counts as even). The remaining parts of the string are joined back together. Whoever cannot move loses. The vowels are a, e, i, o, u. Both players play optimally. Return True if the first player wins, and False otherwise.
Example 1
text='planet' → True

There are two vowels. The first player cuts pla (one vowel), leaving net. The second player must cut a piece with an even number of vowels, say n. The first player takes the whole et, and the second player has no move left.

Example 2
text='rhythm' → False

There are no vowels, so the first player has nothing to cut and loses immediately.

Example 3
text='aei' → True
Constraints
  • 1 ≤ len(text) ≤ 10⁵
  • text consists of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsTake From Any Pile MediumLucky Ticket With Blanks MediumSandwiched Chip Duel MediumStone Pile: Who Moves First EasyXOR Tile Duel Hard
loading Python…
Input
text='planet'
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.