def build_results_dict(tournament_results):
    """
    builds results. Returns an object of the following form:
    {
        team-1: {
            matches_played: int,
            wins: int,
            draws: int,
            losses: int,
            points: int,
        }
        team-2: {
            ...
        }

        ...

        team-n: {
            ...
        }
    }
    """
    if tournament_results == '':
        return {}

    team_stats_dict = {}
    array_of_input = []
    lines = tournament_results.split('\n')
    for line in lines:
        array_of_input.append(line.split(';'))

    for result in array_of_input:
        for team in result[0:2]:
            if team not in team_stats_dict:
                team_stats_dict[team] = {'matches_played': 0,
                                         'wins': 0,
                                         'draws': 0,
                                         'losses': 0,
                                         'points': 0,}

        if result[2] == "win":
            team_stats_dict[result[0]]['wins'] += 1
            team_stats_dict[result[0]]['points'] += 3
            team_stats_dict[result[1]]['losses'] += 1
        elif result[2] == "loss":
            team_stats_dict[result[0]]['losses'] += 1
            team_stats_dict[result[1]]['wins'] += 1
            team_stats_dict[result[1]]['points'] += 3
        elif result[2] == "draw":
            team_stats_dict[result[0]]['draws'] += 1
            team_stats_dict[result[1]]['draws'] += 1
            team_stats_dict[result[0]]['points'] += 1
            team_stats_dict[result[1]]['points'] += 1

        team_stats_dict[result[0]]['matches_played'] += 1
        team_stats_dict[result[1]]['matches_played'] += 1
    return team_stats_dict