def score(hand):
    """
    Compute the maximal score for a Yahtzee hand according to the
    upper section of the Yahtzee score card.

    hand: full yahtzee hand

    Returns an integer score 
    """
    
    max_score = 0
    
    for idx in range(max(hand) + 1):
        idx_score = hand.count(idx) * idx

        max_score = max(idx_score, max_score)
            
    return max_score