import math


def log_likelihood(rankings, strengths):
    """Compute the log-likelihood of Plackett--Luce model parameters.

    Args:
        rankings (List[tuple]): The data (partial rankings.)
        strengths (List[float]): The model parameters.

    Returns:
        loglik (float): the log-likelihood of the parameters given the data.
    """
    loglik = 0
    for ranking in rankings:
        sum_ = sum(strengths[x] for x in ranking)
        for i, winner in enumerate(ranking[:-1]):
            loglik += math.log(strengths[winner])
            loglik -= math.log(sum_)
            sum_ -= strengths[winner]
    return loglik