Python: Recursive: Max Coins

There are multiple bags each containing known number of coins. If you take a bag, you cannot take any of its neighboring bags. Write a recursive function that takes a list containing the information about number of coins in each bag and returns the maximum possible number of coins you can take from all bags.


max_coins([9, 7, 14, 18, 6]) -> 29
max_coins([1, 2, 3, 4, 5, 6]) -> 12

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6    

Test 7    

Test 8