Nim game winner
Your task
Two players alternate turns in a game of Nim: there are several piles of stones, and on each turn a player removes one or more stones from a single pile. The player who cannot move (all piles empty) loses. Given the pile sizes, return True if the player who moves first has a winning strategy under optimal play, else False. Use the Sprague-Grundy / Nim-sum theorem: the first player wins iff the XOR of all pile sizes is non-zero.
Examples
nim_first_player_wins(piles: list[int]) -> boolExample 1
Input
nim_first_player_wins([3, 4, 5])Output
True