예제 #1
0
파일: triomino.py 프로젝트: siloprince/dlx
def solve(p, q):
    c = [0]

    def counter(xs):
        print xs
        c[0] += 1

    if (p * q) % 3 != 0:
        return

    ls = makeTiling(p, q)
    dlx.algoDLX(counter, ls)
예제 #2
0
def solve(xscale=1, ypiece=4, xslide=0, yslide=0):
    c = [0]

    def counter(xs):
        print xs
        if len(xs) > 0:
            c[0] += 1

    if (xslide * yslide == 0):
        xpiece = xscale * 7
        ls = repeatxmond.place(xpiece, ypiece, xslide, yslide)
        print ls
        dlx.algoDLX(counter, ls)

    return c[0]
예제 #3
0
def solve(subdiv):
    c = [0]
    def counter(xs):
        print xs
        if len(xs)>0:
            c[0] += 1

    ymax = 6
    xmax = 6
    picked = [7,8,9,15,16,17,18,19,20,21,22,23,26,27,28,29,30,31,32,33,34,37,38,39,40,41,42,43,44,45,48,49,50,51,52,53,54,55,56,62,63,64]
 
    inside = xmond.getInside(subdiv,xmax,ymax,picked)
    ls = xmond.place(subdiv,xmax,ymax,inside)
    dlx.algoDLX(counter, ls)
    return c[0]
예제 #4
0
파일: sample.py 프로젝트: siloprince/dlx
def solve(subdiv):
    c = [0]

    def counter(xs):
        print xs
        if len(xs) > 0:
            c[0] += 1

    ymax = 8
    xmax = 8
    picked = [1, 2, 3, 4, 5, 16, 17, 18, 19, 20]

    inside = xpentamond.getInside(subdiv, xmax, ymax, picked)
    ls = xpentamond.place(subdiv, xmax, ymax, inside)
    dlx.algoDLX(counter, ls)
    return c[0]
예제 #5
0
def solve(subdiv):
    c = [0]

    def counter(xs):
        print xs
        if len(xs) > 0:
            c[0] += 1

    ymax = 24
    xmax = 24
    scale = 1
    picked = [3, 4, 5, 49, 50, 51, 52, 53, 96, 97, 98, 99, 100, 144, 145, 146]

    inside = xtrapezoid.getInside(subdiv, xmax, ymax, picked)
    ls = xtrapezoid.place(subdiv, xmax, ymax, inside)
    dlx.algoDLX(counter, ls)
    return c[0]
예제 #6
0
def solve(combo):
    check = []
    chcount = 0
    magic = 0
    for cv in combo:
        chcount += 1
        magic += cv * chcount
        for ci in xrange(0, cv):
            check.append(str(chcount))
    checkstr = ",".join(check)
    csum = 0
    for cv in combo:
        csum += cv

    raw = []
    compiled = []

    c = [0]

    def counter(xs):

        if (True):
            ele2 = []
            for xa in xs:
                for xv in xa:
                    ele2.append(xv)

            if len(ele2) != magic:
                return
            if (len(list(set(ele2))) != magic):
                return

        if (len(xs) == csum):
            #print xs
            msum = 0
            for xv in xs:
                msum += len(xv)

            if msum == magic:
                output = []
                ele = []
                for xv in xs:
                    output.append(str(len(xv)))
                    ele.append(str(len(xv)))
                ele.sort()
                #print output
                if ",".join(ele) == checkstr:
                    #print output
                    raw.append(",".join(output))
                    for xv in xs:
                        output.append(str(len(xv)))
                    output.append(":")
                    rxs = list(xs)
                    rxs.reverse()
                    for rxv in rxs:
                        output.append(str(len(rxv)))
                    for rxv in rxs:
                        output.append(str(len(rxv)))
                    j = ",".join(output)
                    compiled.append(j)
                    c[0] += 1

    ls = makeTiling(magic, combo)
    dlx.algoDLX(counter, ls)

    same = []
    for cv in compiled:
        same.append(-1)
    rcount = 0
    for rv in raw:
        ccount = 0
        for cv in compiled:
            if same[ccount] == -1:
                if cv.find(rv) >= 0:
                    same[ccount] = rcount
            ccount += 1
        rcount += 1
    #print c[0]
    uniq = list(set(same))
    result = []
    for ui in uniq:
        result.append(raw[ui])
    print len(result)
    print result
    print ","
    return c[0]