You are viewing a single comment's thread. Return to all comments →
python3 slow version:
def gamingArray(arr): number_of_moves = 0 while len(arr) != 0: number_of_moves += 1 arr = arr[:arr.index(max(arr))] if number_of_moves % 2 == 0: return "ANDY" return "BOB"
fast version:
def gamingArray(arr): number_of_moves = 0 moves = [(0, arr[0])] for i, number in enumerate(arr[1:]): if number > moves[-1][1]: moves.append((i+1, number)) if len(moves) % 2 == 0: return "ANDY" return "BOB"
Seems like cookies are disabled on this browser, please enable them to open this website
Gaming Array 1
You are viewing a single comment's thread. Return to all comments →
python3 slow version:
fast version: