def three_way_split_indices(size, pct_b, pct_c):
    """
    Utility for splitting an array
    Returns (a, b) where a and b are indices for splitting the array into 3 pieces

    Arguments:
    size -- the size of the array
    pct_b -- the percent of the array that should be used for group b
    pct_c -- the percent of the array that should be used for group c
    """
    assert 0 <= pct_b <= 100
    assert 0 <= pct_c <= 100
    pct_a = 100 - (pct_b + pct_c)
    assert 0 <= pct_a <= 100

    if pct_a >= 100:
        return size, size
    elif pct_b >= 100:
        return 0, size
    elif pct_c >= 100:
        return 0, 0
    else:
        a = int(round(float(size)*pct_a/100))
        if pct_a and not a:
            a = 1
        b = int(round(float(size)*pct_b/100))
        if a + b > size:
            b = size - a
        if pct_b and not b:
            if a > 1:
                a -= 1
                b = 1
            elif a != size:
                b = 1
        c = size - (a + b)
        if pct_c and not c:
            if b > 1:
                b -= 1
                c = 1
            elif a > 1:
                a -= 1
                c = 1
        assert a+b+c == size
        return a, a+b