"Bricks Game" from HackerRank
<p>I've been trying to solve <a href="https://www.hackerrank.com/contests/101apr14/challenges/play-game" rel="nofollow">this</a> problem from HackerRank's Dynamic Programming section. I read the editorial solution and understand it. However, it jumps straight to dynamic programming approach. I want to know what would the brute force approach be for this problem. </p>

<blockquote>
  <p><strong>Description:</strong> You and your friend decide to play a game using a stack consisting of N bricks. In this game, you can alternatively remove 1, 2 or 3 bricks from the top, and the numbers etched on the removed bricks are added to your score. You have to play so that you obtain the maximum possible score. It is given that your friend will also play optimally and you make the first move.</p>
</blockquote>

<p>My initial thought is to enumerate all possible 1,2,3-length combinations combinations of bricks, starting from the top of stack down to the bottom. Let's call this enumeration S. Then, find all possible (x,y) for all x (your score) and y (opponent's score) in S, where x != y. Finally iterate, through all such pairs and compute your maximum score (e.g. max sum of x's). </p>