import random


def randomFlips(n, p):
    """
     Return an array of length n of random bits {0, 1} where Probability(0) = p and Probability(1) = 1 - p
     this is used for randomly selecting some of the tokens for vertical placement.
    """

    ans = n*[0]
    for i in range(n):
        x = random.random()
        if x > p:
            ans[i] = 1

    return ans