ticket of even length. It contains digits and ? blanks. They take turns, Alice first: on each turn the player picks any remaining ? and writes a digit from 0 to 9 in its place. The game ends when no blanks are left.
If the digits of the first half of the ticket add up to the same total as the digits of the second half, the ticket is "lucky" and Bob wins. Otherwise Alice wins. If there are no blanks to begin with, the winner is decided right away.
Both play perfectly. Return True if Alice wins and False if Bob wins.ticket="18?9" → True
There is a single blank and it goes to Alice. The left half sums to 1 + 8 = 9 and the right has 9 plus the blank, so any digit except 0 breaks the tie.
ticket="??09" → False
Both blanks are on the left and the right sums to 0 + 9 = 9. Whatever digit d Alice writes, Bob writes 9 - d in the other blank, so the left also sums to 9.
ticket="4422" → True
ticket consists of digits and ? charactersticket="18?9"
True
Run checks the first 3 tests in your browser. Submit checks all 164 tests on the server, hidden ones included.