Untitled
unknown
plain_text
5 months ago
512 B
5
Indexable
def gameWinner(colors): wendy_moves = 0 bob_moves = 0 # Iterate through the string to count possible moves n = len(colors) for i in range(1, n - 1): if colors[i - 1] == colors[i] == colors[i + 1]: if colors[i] == 'w': wendy_moves += 1 elif colors[i] == 'b': bob_moves += 1 # Determine the winner based on who has more moves if wendy_moves > bob_moves: return 'wendy' else: return 'bob'
Editor is loading...
Leave a Comment