Coins from a row - a game
Question
Suppose you are creating an allocation game with the following parameters:
- There are two players sitting across a row of bills with varying dollar values
- In each turn, one of the players will select either the first or last bill from the row, receiving the value shown
- You can assume that there are an even number of bills (meaning each player receives the same # of bills)
- Each player will receive the maximum bill on either end of the array in a given turn
Given this information, and a set of bills in an array, write code simulate the projected returns of this game between each player.
For example:
bills = [1, 1, 2, 20]
# Output =
# Player one: (20 + 1) = 21
# Player two: (1 + 2) = 3
# P1 chooses 20, P2 left with 1, P2 chooses 2, P1 left with 1