Exemplo n.º 1
0
def main(args):
    m = set()
    for p in permute.all_perms([1, 2, 3, 4, 5, 6, 7, 8, 9]):
        n = check(p)
        if (n > 0):
            m.add(n)

    logging.info(sum(m))
Exemplo n.º 2
0
def ispanprime(d, prime):
    mp = 0
    for p in permute.all_perms(d):
        n = 0
        for i in p:
            n = n*10 + i
        if (prime.IsPrime(n) and n > mp):
            mp = n
    return mp
Exemplo n.º 3
0
def main(args):
    s = 0

    for p in permute.all_perms('0123456789'):
        if (check(p)):
            s += int(p)

    logging.info(s)

    
Exemplo n.º 4
0
def main(args):
    p3 = []
    p4 = []
    p5 = []
    p6 = []
    p7 = []
    p8 = []

    n = 10
    temp = n * (n + 1) // 2
    while (temp < 10000):
        if (temp > 1000): p3.append(temp)
        temp = n * n
        if (temp > 1000 and temp < 10000): p4.append(temp)
        temp = n * (3 * n - 1) // 2
        if (temp > 1000 and temp < 10000): p5.append(temp)
        temp = n * (2 * n - 1)
        if (temp > 1000 and temp < 10000): p6.append(temp)
        temp = n * (5 * n - 3) // 2
        if (temp > 1000 and temp < 10000): p7.append(temp)
        temp = n * (3 * n - 2)
        if (temp > 1000 and temp < 10000): p8.append(temp)
        n += 1
        temp = n * (n + 1) // 2

    p = [p3, p4, p5, p6, p7, p8]

    for idx in permute.all_perms(list(range(1, 6))):
        for n1 in p3:
            for n2 in p[idx[0]]:
                if (not IsCyclic(n1, n2)): continue
                for n3 in p[idx[1]]:
                    if (not IsCyclic(n2, n3)): continue
                    for n4 in p[idx[2]]:
                        if (not IsCyclic(n3, n4)): continue
                        for n5 in p[idx[3]]:
                            if (not IsCyclic(n4, n5)): continue
                            for n6 in p[idx[4]]:
                                if (not IsCyclic(n5, n6)): continue
                                if (IsCyclic(n6, n1)):
                                    logging.info((n1, n2, n3, n4, n5, n6))
                                    logging.info(idx)
                                    logging.info(sum([n1, n2, n3, n4, n5, n6]))
Exemplo n.º 5
0
def FormExpression(my_str):
    three_ops = Form3Ops()
    expressions = []
    for n in permute.all_perms(my_str):
        a = str(n[0])
        b = str(n[1])
        c = str(n[2])
        d = str(n[3])
        for op in three_ops:
            my_express = a + op[0] + b + op[1] + c + op[2] + d
            expressions.append(my_express)
            my_express = '(' + a + op[0] + b + ')' + op[1] + c + op[2] + d
            expressions.append(my_express)
            my_express = '(' + a + op[0] + b + op[1] + c + ')' + op[2] + d
            expressions.append(my_express)
            my_express = a + op[0] + '(' + b + op[1] + c + ')' + op[2] + d
            expressions.append(my_express)
            my_express = a + op[0] + '(' + b + op[1] + c + op[2] + d + ')'
            expressions.append(my_express)
            my_express = a + op[0] + b + op[1] + '(' + c + op[2] + d + ')'
            expressions.append(my_express)
            my_express = '(' + a + op[0] + b + ')' + op[1] + '(' + c + op[
                2] + d + ')'
            expressions.append(my_express)
            my_express = '((' + a + op[0] + b + ')' + op[1] + c + ')' + op[
                2] + d
            expressions.append(my_express)
            my_express = '(' + a + op[0] + '(' + b + op[1] + c + '))' + op[
                2] + d
            expressions.append(my_express)
            my_express = a + op[0] + '((' + b + op[1] + c + ')' + op[
                2] + d + ')'
            expressions.append(my_express)
            my_express = a + op[0] + '(' + b + op[1] + '(' + c + op[
                2] + d + '))'
            expressions.append(my_express)
    return expressions