## Task
 In your favorite game, you must shoot a target with a water-gun to gain points. Each target can be worth a different amount of points. 
 
 You are guaranteed to hit every target that you try to hit. You cannot hit consecutive targets though because targets are only visible for one second (one at a time) and it takes you a full second to reload your water-gun after shooting (you start the game already loaded).

 Given an array `vals` with the order of each target's point value, determine the maximum number of points that you can win.

## Example
 For `vals = [1, 2, 3, 4]`, the result should be `6`.
 
 your optimal strategy would be to let the first one pass and shoot the second one with value 2 and the 4th one with value 4 thus:

 `vals[1](2) + vals[3](4) = 6`
 
 For `vals = [5, 5, 5, 5, 5]`, the result should be `15`.
 
 your optimal strategy would be to shoot the 1st, 3rd and 5th value:
 
 `5 + 5 + 5 = 15`
 
 You haven't shoot the 2nd, 4th value because you are reloading your water-gun after shooting other values.
 
 Note that the value can be zero or negative, don't shoot them ;-)
 
 For `vals = [0, 0, -1, -1]`, the result should be `0`.
 
 For `vals = [5, -2, -9, -4]`, the result should be `5`.
 
 Shoot the first one is enough.
 
## Input/Output


 - `[input]` integer array `vals`

  The point values (negative or non-negative) of the targets (in order of appearance).


 - `[output]` an integer

  The maximum number of points that you can score.

Difficulty: introductory

Starter code:

def target_game(values):
	

Solutions:
def target_game(values):
    a = b = 0
    for n in values:
        a, b = b, max(a + n, b)
    return max(a, b)

def target_game(values):
    max_can_shoot, max_can_not_shoot = 0, 0
    for val in values:
        new = max_can_shoot + val
        max_can_shoot = max(max_can_not_shoot, new)
        max_can_shoot, max_can_not_shoot = max_can_not_shoot, max_can_shoot
    return max(max_can_shoot, max_can_not_shoot)

from functools import lru_cache

def target_game(values):
    @lru_cache(maxsize=None)
    def rec(i):
        if i >= len(values): return 0
        if values[i] <= 0: return rec(i+1)
        return max(rec(i+1), values[i]+rec(i+2))
    return rec(0)

def target_game(values):
    n = len(values)
    dp = [0] * (n + 1)
    dp[1] = values[0] if values[0] > 0 else 0
    for ind in range(2, n + 1):
        dont_take = dp[ind - 1]
        take = dp[ind - 2] + values[ind - 1] if values[ind - 1] > 0 else dp[ind - 2]
        dp[ind] = max(dont_take, take)
    return dp[n]

def target_game(values):
    dicto = {}
    def target_games(values,ind=0,reloaded=True,sumo=0):
        key = f"ind {ind} sumo {sumo} reloaded {reloaded}"
        if key in dicto: return dicto[key]
        if ind >= len(values): return sumo
        while values[ind] < 0:
            ind += 1
            reloaded = True
            if ind == len(values): return sumo
        if reloaded: d = target_games(values,ind+1,not reloaded,sumo+values[ind])
        elif not reloaded: d = target_games(values,ind+1,not reloaded,sumo)
        f = target_games(values,ind+1,reloaded,sumo)
        dicto[key] = max(d,f)
        return dicto[key]
    return target_games(values)

def target_game(values):
    values[2] = get_highest_possible_score(0, values[0], values[2]) 
    for i in range(3,len(values)):
        values[i] = get_highest_possible_score(values[i-3], values[i-2], values[i]) 
    return max(values)

def get_highest_possible_score(a,b,n):
    a = max(0,a)
    b = max(0,b)
    n = max(0,n)
    
    if(a>b):
        return a+n

    return b+n

def target_game(values):
    sum1 = 0
    sum2 = 0
    for value in values:
        sum1 = max(sum1 + value, sum2)
        sum1, sum2 = sum2, sum1
    return max(sum1, sum2)


def target_game(arr):
    # your code goes here
    a = 0
    b = 0
     
    for i in arr: 
        
      newA = a if (a > b) else b
    
      b = a + i
      a = newA
      
    if (a > b):
        return a
    else: 
        return b


def target_game(arr):
    # your code goes here
    a = 0
    b = 0
     
    for i in arr: 
        
      newA = a if (a > b) else b
    
      b = a + i
      a = newA
      
    # return max of incl and excl 
    if (a > b):
        return a
    else: 
        return b


memo={}
def target_game(values):
    if len(values)==1:
        return max(values[0],0)
    elif len(values)==2:
        return max(values[0],values[1],0)
    elif len(values)==3:
        return max(max(values[0],values[2],values[0]+values[2],0),values[1])
    t=tuple(values)
    if t in memo:
        return memo[t]
    r=max(max(values[0],0)+target_game(values[2:]),max(values[1],0)+target_game(values[3:]))
    memo[t]=r
    return r