Pete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun. 

They decide to have a competition. 3 rounds, 2 shots each. Winner is the one with the most hits.

Some of the clays have something attached to create lots of smoke when hit, guarenteed by the packaging to generate 'real excitement!' (genuinely this happened). None of the explosive things actually worked, but for this kata lets say they did.

For each round you will receive the following format:

[{P1:'XX', P2:'XO'}, true]

That is an array containing an object and a boolean. Pl represents Pete, P2 represents Phil. X represents a hit and O represents a miss. If the boolean is true, any hit is worth 2. If it is false, any hit is worth 1.

Find out who won. If it's Pete, return 'Pete Wins!'. If it is Phil, return 'Phil Wins!'. If the scores are equal, return 'Draw!'.

Note that as there are three rounds, the actual input (x) will look something like this:

[[{P1:'XX', P2:'XO'}, true], [{P1:'OX', P2:'OO'}, false], [{P1:'XX', P2:'OX'}, true]]

Difficulty: introductory

Starter code:

def shoot(results):
	

Solutions:
def shoot(results):
    pete = phil = 0
    
    for shots, double in results:
        pete += shots["P1"].count("X") * (1 + double)
        phil += shots["P2"].count("X") * (1 + double)
    
    return "Pete Wins!" if pete > phil else "Phil Wins!" if phil > pete else "Draw!"

def shoot(results):
    pt1, pt2 = 0, 0
    countPts = lambda elt,pt: (elt[1]+1)*elt[0][pt].count('X')
    for elt in results:
        pt1 += countPts(elt,'P1')
        pt2 += countPts(elt,'P2')
    if pt1>pt2 :     return 'Pete Wins!'
    elif pt1==pt2 :  return 'Draw!'
    else:            return 'Phil Wins!'

# Works for any number of rounds or shots
def shoot(results):
    P1 = P2 = 0
    for D, b in results:
        P1 += D["P1"].count('X') * (b + 1)
        P2 += D["P2"].count('X') * (b + 1)
    return ("Draw!", "Pete Wins!", "Phil Wins!")[(P1>P2) - (P1<P2)]

def shoot(results):
    score = sum(rnd[f"P{i+1}"].count("X") * (mul + 1) * (-1)**i for i in (0, 1) for rnd, mul in results)
    return "Pete Wins!" if score > 0 else "Phil Wins!" if score < 0 else "Draw!"


def shoot(a):
    main = {}
    for i, j in a:
        hit = 2 if j else 1
        main["p1"] = main.get("p1", 0) + i['P1'].count("X")*hit
        main["p2"] = main.get("p2", 0) + i['P2'].count("X")*hit
    return ["Draw!", ["Pete Wins!", "Phil Wins!"][main["p1"] < main["p2"]]][main["p1"] != main["p2"]]

def shoot(results):
  pete, phil = [sum(d[p].count('X') * (1+b) for d, b in results) for p in ['P1', 'P2']]
  return 'Pete Wins!' if pete > phil else 'Phil Wins!' if phil > pete else 'Draw!'

def shoot(results):
    pete, phil = (sum(r[player].count('X') * (1+dbl) for r, dbl in results) for player in ['P1', 'P2'])
    return 'Pete Wins!' if pete > phil else 'Phil Wins!' if phil > pete else 'Draw!'

def shoot(arr):
    pete, phil = 0, 0
    for i in arr:
        score = 2 if i[1] == True else 1
        pete += i[0]['P1'].count('X')*score
        phil += i[0]['P2'].count('X')*score
    return "Pete Wins!" if pete > phil else "Phil Wins!" if phil > pete else "Draw!"

def shoot(results):
    p1_score = 0
    p2_score = 0
    
    for round in results:
        if round[1]:
            inc = 2
        else:
            inc = 1
        
        p1_shoots = round[0]['P1']
        p2_shoots = round[0]['P2']
        
        for shoot in p1_shoots:
            if shoot == 'X':
                p1_score += inc
                
        for shoot in p2_shoots:
            if shoot == 'X':
                p2_score += inc
    
    if p1_score > p2_score:
        return 'Pete Wins!'
    elif p1_score < p2_score:
        return 'Phil Wins!'
    else:
        return 'Draw!'