def getContinuousRuns(x):
    """
    Given a 1D array, find all of the continuous runs
    of 1s, and count the numbers with a certain length
    :param x: 1D array
    :returns Runs: A frequency distribution dictionary of
        the form {length:counts}
    """
    Runs = {}
    (IN_ZEROS, IN_ONES) = (0, 1)
    state = IN_ZEROS
    count = 0
    for i in range(len(x)):
        if state == IN_ZEROS:
            if x[i] == 1:
                state = IN_ONES
                count = 1
        elif state == IN_ONES:
            if x[i] == 0:
                if not count in Runs:
                    Runs[count] = 0
                Runs[count] += 1
                state = IN_ZEROS
            elif x[i] == 1:
                count += 1
    return Runs