**This Kata is intended as a small challenge for my students**

All Star Code Challenge #23

There is a certain multiplayer game where players are assessed at the end of the game for merit. Players are ranked according to an internal scoring system that players don't see.

You've discovered the formula for the scoring system!

Create a function called `scoring()` that takes an array of Player objects and returns an array of player names, in order of descending score (highest score is index 0, 2nd highest is index 1, etc.).

Each player's score is calculated as follows:

1. Each normal kill is worth 100 points
2. Each assist is worth 50 points
3. Each point of damage done is worth .5 points
4. Each point of healing done is worth 1 point
5. The longest kill streak is worth 2^N, where N is the number of kills of the streak
6. Environmental kills are worth 500 points (These are counted separately from normal kills)

For each of the above statistic, a Player object contains a respective "key:value" pairing. All values except the 'name' are integers.

Note:  
Assume the input array will ALWAYS have a properly constructed Player object (no missing keys or values)  
Names will not contain unusual characters nor repeat (names are unique)  
Players with the same score should be sorted by the order they appear in the array  
For simplicity, for a kill streak of 0 the kill streak calculation will yield 1 (or 2^(0)) points

Difficulty: introductory

Starter code:

def scoring(array):
	

Solutions:
def scoring(array):
    res = {}
    
    for e in array:
        score = e["norm_kill"] * 100 + e["assist"] * 50 + e["damage"] // 2 +\
        e["healing"] + 2 ** e["streak"] + e["env_kill"] * 500
        
        res[e["name"]] = score
    
    return sorted(res, key=res.get, reverse=True)

def scoring(array):
    return [i["name"] for i in sorted(array, key=lambda x: (x["norm_kill"] * 100 + x["assist"] * 50 + x["damage"] * .5 +
                                                            x["healing"] + 2 ** x["streak"] + x["env_kill"] * 500), reverse=True)]

values = (("norm_kill", (100).__mul__),
          ("assist", (50).__mul__),
          ("damage", (0.5).__mul__),
          ("healing", (1).__mul__),
          ("streak", (2).__pow__),
          ("env_kill", (500).__mul__))

def score(player):
    return sum(f(player[k]) for k,f in values)

def scoring(array):
    return [player["name"] for player in sorted(array, key=score, reverse=True)]

def scoring(array):
    points= { 'assist': lambda a: a * 50, 'damage': lambda a: a * 0.5, 
              'streak': lambda a: 2**a , 'norm_kill': lambda a: a * 100, 
              'healing': lambda a: a * 1, 'env_kill': lambda a: a * 500 }
    
    sum_score = { e['name']:sum(points[k](v) for k, v in  list(e.items()) if isinstance(v , int)) for e in array}
    
    return sorted(sum_score, key=sum_score.get, reverse=True)
    


def score(x):
    return (x['norm_kill'] * 100
          + x['assist'] * 50
          + x['damage'] * 0.5
          + x['healing'] * 1
          + 2 ** x['streak']
          + x['env_kill'] * 500)

def scoring(array):
    return [x['name'] for x in sorted(array, key=score, reverse=True)]

COEFS = (("norm_kill", 100), ("assist", 50), ("damage", .5), ("healing", 1), ("env_kill", 500))

def scoring(arr):
    return [p['name'] for p in sorted(arr, key=lambda p: -(sum(p[k]*c for k,c in COEFS) + 2**p['streak']) )]

def scoring(array):
    scores = []
    output = []
    
    for ply in array:
        score = (ply['norm_kill'] * 100) + (ply['assist'] * 50) + (ply['damage'] * 0.50) + ply['healing'] + (2 ** ply['streak']) + (ply['env_kill'] * 500)
        scores.append((ply['name'], score))
    
    def getScore(tup):
        return tup[1]
    
    players = sorted(scores, key=getScore, reverse=True)

    for player in players:
        output.append(player[0])
        
    return output

def scoring(array):
    res = {e["name"]: e["norm_kill"] * 100 + e["assist"] * 50 + e["damage"] // 2 +\
        e["healing"] + 2 ** e["streak"] + e["env_kill"] * 500 for e in array}
    
    return sorted(res, key=res.get, reverse=True)

import operator

calculations = {
    'norm_kill': lambda x: x * 100,
    'assist': lambda x: x * 50,
    'damage': lambda x: x * .5,
    'healing': lambda x: x * 1,
    'streak': lambda x: 2 ** x,
    'env_kill': lambda x: x * 500
}


def scoring(array):
    leaderboard = {}
    for player in array:
        score = 0
        for action, value in player.items():
            if action in calculations:
                score += calculations[action](value)
        leaderboard[player['name']] = score
    return [name for name, score in sorted(leaderboard.items(), key=operator.itemgetter(1), reverse=True)]

def scoring(array):
    score_table = {"norm_kill": 100, "assist": 50, "damage": 0.5, "healing": 1, "env_kill": 500}
    scores = [(-sum(p[stat]*v for stat, v in score_table.items()) - 2**p["streak"], i, p["name"]) for i, p in enumerate(array)]
    return [name for s, i, name in sorted(scores)]