def split_int(i, p):
    """
    Split i into p buckets, such that the bucket size is as equal as possible
    Args:
        i: integer to be split
        p: number of buckets

    Returns: list of length p, such that sum(list) = i, and the list entries differ by at most 1

    """
    split = []
    n = i / p  # min items per subsequence
    r = i % p  # remaindered items

    for i in range(p):
        split.append(int(n + (i < r)))

    return split