This should be sufficient:

    def _get_fast_corner_response(bins, state, n):
        consecutive_count = 0
        sum_state = 0
        for l in range(15 + n):
            if bins[l % 16] == state:
                consecutive_count += 1
                if consecutive_count == n:
                    for m in range(16):
                        if bins[m] == state:
                            sum_state += 1
                    break
            else:
                consecutive_count = 0
        return sum_state


    a = ['b', 'b', 'b', 'b', 'b', 'd', 'd', 'd', 'd', 'b', 'b', 'b', 'b', 'b', 'b', 'b']

    print _get_fast_corner_response(a, 'b', 12)


Note, that the sum is not calculated correctly… the script was just for testing purposes.