• + 0 comments

    For anyone stuck, here's a 2 line function that shows logic of the final solution:

    def makeMove(arr):
        if len(arr) <= 3: return sum(arr)
        return sum(arr) - min([makeMove(arr[i : len(arr)]) for i in range(1, 4)])
    

    It gives correct answer, but is not optimal. In order to solve it properly, it needs to be implemented using iteration instead of recursion