import math


def euclid(onsets, pulses):
    """returns a list of ones and zeros for a give euclidean rhythm

    >>> euclid(3,8)
    [1, 0, 0, 1, 0, 0, 1, 0]
    """
    slope = float(onsets) / float(pulses)
    result = []
    previous = None
    for i in range(pulses):
        current = int(math.floor(float(i) * slope))
        result.append(int(current != previous if 1 else 0))
        previous = current
    return result