Esempio n. 1
0
def ans():
    largest = 0
    for i in range(10000):
        string = ''
        for product in [i * j for j in range(1, 10)]:
            string += str(product)
            if 9 < len(string):
                break
            if is_pandigital(string, to=9) and largest < int(string):
                largest = int(string)
    return largest
Esempio n. 2
0
def ans():
    products = set()
    for i in range(1, 2000):
        for j in range(i, 2000):
            product = i * j
            string = str(i) + str(j) + str(product)
            length = len(string)
            if 9 < length:
                break
            if is_pandigital(int(string), to=9):
                products.add(product)
    return sum(products)
Esempio n. 3
0
            #print r
            #print
            #print s[0:9]
            #print s[-9:]
            #print
            #print k
            #break


while True:
    r = fibo.next()[-9:]
    k += 1
    if k == 541:
        print r
        print 'trololo'
        print 'lala', pandigital.is_pandigital(r)
    if len(str(r)) < 9:
        continue
    s = str(r)
    if k % 1000 == 0:
        print k
    if pandigital.is_pandigital(s):
        f = str(fibonacci.fibonacci(k))
        print k, s, f[0:9]
        if pandigital.is_pandigital(f[0:9]):
            print r
            print
            print f[0:9]
            print f[-9:]
            print
            print k
Esempio n. 4
0
from pandigital import is_pandigital

assert is_pandigital(1) == False
assert is_pandigital(1, 2) == False
assert is_pandigital('10', 2) == True
assert is_pandigital('10', 2, True) == False
assert is_pandigital('110', 2, unique=True) == False

assert is_pandigital(1234567890) == True
assert is_pandigital(1234567890, zeroless=True) == False

assert is_pandigital(123, b=4, zeroless=True) == True
assert is_pandigital('021', b=3) == True
assert is_pandigital('021', b=3, unique=True) == True
Esempio n. 5
0
def solution():
    """i only bother searching for i = 2 as this gave a correct solution"""   
    x = {int(str(n*1)+str(n*2)) for n in range(0,9999) if (len(str(n*1)+str(n*2))==9 and pandigital.is_pandigital({n*1, n*2}))}

    return max(x) 
# 192 × 3 = 576
#
# By concatenating each product we get the 1 to 9 pandigital, 192384576.
# We will call 192384576 the concatenated product of 192 and (1,2,3)
#
# The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5,
# giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).
#
# What is the largest 1 to 9 pandigital 9-digit number that can be formed as the
# concatenated product of an integer with (1,2, ... , n) where n > 1?

from pandigital import is_pandigital

largest_pandigital = 0
# The largest number with pandigital potential that can be multiplied to a total of nine digits
# one of the given numbers starts with 9, so we must limit ourselves to start with numbers that start with 9
for i in range(9876, 8, -1):
    lp = str(i)
    if '0' in str(
            i
    ):  # if 0 is in the number it does not fit the given definition of pandigital
        continue
    for n in range(2, 6):  # our largest n is 5, as shown in the example
        lp += str(i * n)
        if len(lp) >= 9:
            break
    if is_pandigital(lp) and int(lp) > largest_pandigital:
        largest_pandigital = int(lp)

print(largest_pandigital)  # 932718654
Esempio n. 7
0
import pandigital

results = set()

for i in range(1, 10000000001):
    if i % 1000 == 0:
        print(i, results)
    for j in range(1, 1000000001):
        r = i * j
        if len(str(i) + str(j) + str(r)) > 9:
            break
        if j % 100 == 0:
            print('#', i, j, r)

        if pandigital.is_pandigital(str(i) + str(j) + str(r)):
            print(i, j, r)
            results.add(r)