Exemplo n.º 1
0
def compute():

    valid_pandigitals = []

    for x in range(1, 10):
        concat = str(x) + str(x * 2) + str(x * 3) + str(x * 4) + str(x * 5)
        if is_pandigital(concat):
            valid_pandigitals.append(concat)

    for x in range(10, 100):
        concat = str(x) + str(x * 2) + str(x * 3) + str(x * 4)
        if is_pandigital(concat):
            valid_pandigitals.append(concat)

    for x in range(100, 1000):
        concat = str(x) + str(x * 2) + str(x * 3)
        if is_pandigital(concat):
            valid_pandigitals.append(concat)

    for x in range(1000, 10000):
        concat = str(x) + str(x * 2)
        if is_pandigital(concat):
            valid_pandigitals.append(concat)

    return max(valid_pandigitals)
Exemplo n.º 2
0
def first_digits():

    n, m = 1, 1
    poss_k1 = []
    for k in range(3, 5 * 10**5):
        l = int(str(n + m)[:20])
        if is_pandigital(str(l)):
            poss_k1.append(k)
        n, m = m, l
    return poss_k1
Exemplo n.º 3
0
def last_digits():

    n, m = 1, 1
    poss_k2 = []
    for k in range(3, 5 * 10**5):
        l = int(str(n + m)[-10:])
        if is_pandigital(str(l)):
            poss_k2.append(k)
        n, m = m, l
    return poss_k2
Exemplo n.º 4
0
def find_largest_concatenation_of_products():
    lower_bound = 918273645
    upper_bound = 987654321

    for n in range(upper_bound, lower_bound, -1):
        if not is_pandigital(n):
            continue

        if is_concatenation_of_products(n):
            return n
Exemplo n.º 5
0
def is_expression_pandigital(m1, m2, p):
    '''
    The digits 1 to 9 must be included in the expression m1 * m2 = p
    exactly once each
    '''
    return is_pandigital("%s%s%s" % (m1, m2, p))