Пример #1
0
def main():

    s = time.time()

    a_list = range(1, 10000)
    b_list = range(100, 10000)

    pan_list = []

    for a in a_list:
        for b in b_list:
            product = a * b
            p_length = mwmath.count_digits(product) + mwmath.count_digits(
                a) + mwmath.count_digits(b)

            if p_length < 9:
                continue
            if p_length > 9:
                break

            full_term = int(str(a) + str(b) + str(product))

            if mwmath.is_pandigital(full_term):
                if not product in pan_list:
                    pan_list.append(product)

    return [sum(pan_list), time.time() - s]
Пример #2
0
def main():

    s = time.time()
    
    a_list = range(1,10000)
    b_list = range(100,10000)

    pan_list = []

    for a in a_list:
        for b in b_list:
            product = a*b
            p_length = mwmath.count_digits(product)+mwmath.count_digits(a)+mwmath.count_digits(b)

            if p_length<9:
                continue
            if p_length>9:
                break

            full_term = int(str(a)+str(b)+str(product))

            if mwmath.is_pandigital(full_term):
                if not product in pan_list:
                    pan_list.append(product)

    return [sum(pan_list),time.time()-s]
Пример #3
0
import mwmath
import time

s = time.time()

a_list = range(1, 10000)
b_list = range(100, 10000)

pan_list = []

for a in a_list:
    for b in b_list:
        product = a * b
        p_length = mwmath.count_digits(product) + mwmath.count_digits(
            a) + mwmath.count_digits(b)

        if p_length < 9:
            continue
        if p_length > 9:
            break

        full_term = int(str(a) + str(b) + str(product))

        if mwmath.is_pandigital(full_term):
            if not product in pan_list:
                pan_list.append(product)

print sum(pan_list)

print time.time() - s
Пример #4
0
import math
import mwmath
import time

s = time.time()

print mwmath.is_pandigital(1234)
print mwmath.is_pandigital(12343)
print mwmath.is_pandigital(12)
print mwmath.is_pandigital(4312)

potential_primes = []
nn = 10000000
ii = 1000000
while 6*ii<=(nn):
    potential_primes.append(6*ii-1)
    potential_primes.append(6*ii+1)
    ii+=1

pan_list = []

for ele in potential_primes:
    if mwmath.is_pandigital(ele):
        if mwmath.is_prime(ele):
            pan_list.append(ele)
    
print max(pan_list)

print time.time()-s
Пример #5
0
import mwmath
import time

s = time.time()

a_list = range(1,10000)
b_list = range(100,10000)

pan_list = []

for a in a_list:
    for b in b_list:
        product = a*b
        p_length = mwmath.count_digits(product)+mwmath.count_digits(a)+mwmath.count_digits(b)

        if p_length<9:
            continue
        if p_length>9:
            break

        full_term = int(str(a)+str(b)+str(product))

        if mwmath.is_pandigital(full_term):
            if not product in pan_list:
                pan_list.append(product)

print sum(pan_list)


print time.time()-s
Пример #6
0
largest_base = 1
largest_list = 1
largest_pan = 1

pan_list = []

for ele in base_list:
    cur_term = ele
    cur_product = 2

    while mwmath.count_digits(cur_term) < 9:
        cur_term = int(str(cur_term) + str(cur_product * ele))
        cur_product += 1

    if mwmath.count_digits(cur_term) != 9:
        continue
    else:
        if mwmath.is_pandigital(cur_term):
            pan_list.append(cur_term)
            if cur_term > largest_pan:
                print cur_term
                largest_pan = cur_term
                largest_list = cur_product - 1
                largest_base = ele

print pan_list
print largest_base
print largest_list

print time.time() - s
Пример #7
0
import math
import mwmath
import time

s = time.time()

print mwmath.is_pandigital(1234)
print mwmath.is_pandigital(12343)
print mwmath.is_pandigital(12)
print mwmath.is_pandigital(4312)

potential_primes = []
nn = 10000000
ii = 1000000
while 6 * ii <= (nn):
    potential_primes.append(6 * ii - 1)
    potential_primes.append(6 * ii + 1)
    ii += 1

pan_list = []

for ele in potential_primes:
    if mwmath.is_pandigital(ele):
        if mwmath.is_prime(ele):
            pan_list.append(ele)

print max(pan_list)

print time.time() - s
Пример #8
0
largest_list = 1
largest_pan = 1

pan_list = []

for ele in base_list:
    cur_term = ele
    cur_product = 2

    while mwmath.count_digits(cur_term)<9:
        cur_term = int(str(cur_term)+str(cur_product*ele))
        cur_product+=1
        
    if mwmath.count_digits(cur_term)!=9:
        continue
    else:
        if mwmath.is_pandigital(cur_term):
            pan_list.append(cur_term)
            if cur_term>largest_pan:
                print cur_term
                largest_pan = cur_term
                largest_list = cur_product-1
                largest_base = ele

print pan_list
print largest_base
print largest_list
        

print time.time()-s