Exemplo n.º 1
0
def run():
    count = 0
    for i, (num, den) in enumerate(seqGen()):
        if i == 1000:
            return count

        if numDigits(num) > numDigits(den):
            count += 1
Exemplo n.º 2
0
def run():
    pandigitalList = set()
    for a in range(1, 100000):
        lenBMin = 1
        while lenBMin + numDigits(a) < 9:
            b = math.ceil(pow(10, 9 - lenBMin - numDigits(a))/a) #minimum b to produce a total of 9 digits
            while numDigits(a) + numDigits(b) + numDigits(a*b) < 10:
                if isPandigital(a,b,a*b):
                    pandigitalList.add(a*b)
                b += 1 #iterates through all values of b between b min and bmax
            lenBMin += 1 # iterates through all lengths of b

    return sum(pandigitalList)
Exemplo n.º 3
0
def run():
    des = [1, 10, 100, 1000, 10000, 100000, 1000000]

    c = 0
    d = []
    currentD = 0
    for i in range(1, 1000000):

        if c < des[currentD] <= c + numDigits(i):
            d.append(int(str(i)[des[currentD] - c - 1]))
            currentD += 1
            if currentD >= 7:
                break
        c += numDigits(i)

    prod = 1
    for i in d:
        prod *= i

    return prod
Exemplo n.º 4
0
def run():

    count = 1
    for i in range(2, 10):
        p = 1

        while numDigits(i**p) == p:
            count += 1
            #print(i,p,i**p)
            p += 1

    return count
Exemplo n.º 5
0
def run():

    target = 8
    primes = primelist(1000000)
    found = False
    targetExclusionList = ''
    targetRepDigs = ''
    for n in range(2, 8):
        primeSet = list((str(x)) for x in primes if numDigits(x) == n)
        for ex in exclusionList(n):
            currentCount = Counter()
            for p in primeSet:
                repDigs = ''
                changeDigs = ''
                for i, k in enumerate(ex):
                    if k == '1':  #exclude
                        changeDigs += p[i]
                    else:
                        repDigs += p[i]

                if changeDigs.count(changeDigs[0]) == len(
                        changeDigs):  #if all changing digits are equal
                    currentCount[repDigs] += 1
                    if currentCount[repDigs] == target:
                        found = True
                        targetExclusionList = ex
                        targetRepDigs = repDigs
                if found:
                    break
            if found:
                break
        if found:  #go through array again and print answers
            ans = []

            for p in primeSet:
                repDigs = ''
                changeDigs = ''
                for i, k in enumerate(targetExclusionList):
                    if k == '1':  #exclude
                        changeDigs += p[i]
                    else:
                        repDigs += p[i]

                if changeDigs.count(changeDigs[0]) == len(
                        changeDigs):  #if all changing digits are equal
                    if repDigs == targetRepDigs:
                        ans.append(p)
            break

    return min(int(x) for x in ans)
Exemplo n.º 6
0
def run():
    primes = [x for x in primelist(10000) if numDigits(x) == 4]

    for p in primes:
        primePerms = list(set(sorted(x for x in Perms(p) if is_prime(x))))

        while len(primePerms) >= 3:
            diff = primePerms[1] - primePerms[0]
            for n in primePerms[2:]:
                if (n - primePerms[0]) / diff == 2:
                    out = ''.join([str(x) for x in primePerms[0:3]])
                    if len(out) == 12:
                        return int(out)
            primePerms.remove(primePerms[1])
    return -1
Exemplo n.º 7
0
def rightTrunc(x):
    for i in range(numDigits(x) - 1):
        x = (x - x%10)//10
        yield x
Exemplo n.º 8
0
def leftTrunc(x):
    for i in range(numDigits(x) - 1, 0, -1):
        x -= x//10**i*10**i
        yield x
Exemplo n.º 9
0
def CircPerms(x):
    perms = [str(x)]
    for j in range(numDigits(x) - 1):
        perms.append(perms[-1][1:] + perms[-1][0])

    return [int(i) for i in perms]
Exemplo n.º 10
0
def run():
    for i, x in enumerate(Fibonacci()):
        if numDigits(x) == 1000:
            return i + 1