You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
Bricks Game
You are viewing a single comment's thread. Return to all comments →
For anyone stuck, here's a 2 line function that shows logic of the final solution:
It gives correct answer, but is not optimal. In order to solve it properly, it needs to be implemented using iteration instead of recursion