示例#1
0
def concat_nums_2_length():
    n_list = []
    i = 1
    while len(n_list) < 1000001:
        n_list += digits_list(i)
        i += 1
    return map(str, n_list)
示例#2
0
def cubic_perms(n_perms):
    cubed_dict = {}
    for i in count(100):
        ccc = int_from_digits(sorted(digits_list(i**3), reverse=True))
        if ccc in cubed_dict:
            cubed_dict[ccc].append(i)
            if len(cubed_dict[ccc]) > n_perms - 1:
                # print(cubed_dict[ccc])
                return cubed_dict[ccc][0]**3
        else:
            cubed_dict.setdefault(ccc, []).append(i)
示例#3
0
def is_1_2_3_4_5_6_7_8_9_0(n):
    digs = digits_list(n)
    if len(digs) != 19:
        return False
    the_digs = [digs[index] for index in range(0, 19, 2)]
    for i in range(10):
        if i == 9 and the_digs[9] == 0:
            return True
        if i + 1 != the_digs[i]:
            return False
    return True
示例#4
0
def is_bouncy(n):
    digits = digits_list(n)
    increasing = False
    decreasing = False
    for i in range(0, len(digits)-1):
        if digits[i+1] < digits[i]:
            increasing = True
        elif digits[i+1] > digits[i]:
            decreasing = True
        if increasing and decreasing:
            return True
    return False
示例#5
0
def p049():
    four_dig_primes = [i for i in range(1000, 10000) if is_prime(i)]
    num_4dig_primes = len(four_dig_primes)

    prime_perms = defaultdict(list)
    for prime in four_dig_primes:
        sorted_digs = tuple(sorted(digits_list(prime)))
        prime_perms[sorted_digs].append(prime)

    topop = [k for k, v in prime_perms.items() if len(v) < 3]
    for toop in topop:
        prime_perms.pop(toop)

    validsets = []
    for k, v in prime_perms.items():
        for combo in combinations(v, 3):
            if combo[1] - combo[0] == combo[2] - combo[1]:
                validsets.append(combo)

    return int("".join(str(n) for n in validsets[1]))
示例#6
0
def p020():
    return sum(digits_list(factorial(100)))
示例#7
0
def is_circ_prime(n):
    digist = [int(j) for j in digits_list(n)]
    return all((is_prime(int_from_digits(i)) for i in rotations_gen(digist)))
示例#8
0
def is_digit_factorial(n):
    return n == sum(map(factorial, digits_list(n)))
示例#9
0
def digit_factorial(n):
    return sum(digfact[i] for i in digits_list(n))
示例#10
0
def p056():
    return max(
        (sum(digits_list(i**j)) for i in range(1, 100) for j in range(1, 100)))
示例#11
0
def digit_powers(number, power):
    return number == sum(map(lambda x: x**power, digits_list(number)))