Example #1
0
def numsOfWeightMoreThan(n,k):
    leights = numsOfWeight(n, k)
    return [i for i in range(1 << n) if (i not in leights)]
Example #2
0
from numpy.lib.scimath import logn


def numsOfWeightMoreThan(n,k):
    leights = numsOfWeight(n, k)
    return [i for i in range(1 << n) if (i not in leights)]

F = {}

# n=5
# k=2

n=10
k=3

leights = numsOfWeight(n, k)
heavies = numsOfWeightMoreThan(n, k)
    
def isNeighbor(l,h):
    return l&h==l

def neighbors(j):
    return [k for k in heavies if isNeighbor(j, k)]

def neighborsNotAssigned(j):
    neighs = neighbors(j)
    keys = F.keys()
    return [k for k in neighs if (k not in keys)]

def chooseAtRandom (thelist):
    idx = randrange(0,len(thelist))