import math


def percentile(data, pc):
    """Naive algorithm to compute the pc'th percentile of a list of (sorted) data.
    Linear interpolation is used when the percentile lies between two data
    points. It is assumed that the data contains no NaN or similar.
    """
    if pc < 0 or pc > 100:
        raise ValueError('Percentile must be in the range [0, 100].')
    size = len(data)
    if size == 0:
        raise ValueError('Cannot compute percentile of empty list!')
    if size == 1:
        return data[0]
    index = (size - 1) * (pc / 100.0)
    index_floor = math.floor(index)
    index_ceil = math.ceil(index)
    if index_floor == index_ceil:
        return data[int(index)]
    d0 = data[int(index_floor)] * (index_ceil - index)
    d1 = data[int(index_ceil)] * (index - index_floor)
    return d0 + d1