Пример #1
0
def pandigital_product(list):
    """
    >>> pandigital_product([3, 9, 1, 8, 6, 7, 2, 5, 4])
    True
    """
    for i in range(2, 9):
        for j in range(1, i):
            last = list[i:]
            furst = list[:j]
            second = list[j:i]
            if int_from_digits(furst) * int_from_digits(second) == int_from_digits(last):
                return int_from_digits(last)
    return 0
Пример #2
0
def p043():
    # well_they_gave_us_this_one = [1,4,0,6,3,5,7,2,8,9]
    # test_answer = pandigital_substring_thing(well_they_gave_us_this_one)
    # print(test_answer)
    circle_to_nine = [i for i in range(0, 10)]  # circle is the way kids say 0 now a days
    pandigit_lists = [int_from_digits(i) for i in permutations(circle_to_nine) if pandigital_substring_thing(i)]
    return sum(pandigit_lists)
Пример #3
0
def pandigital_substring_thing(pandigit_list):
    if pandigit_list[0] == 0:
        return False  # leading 0 shouldnt count
    else:
        div_primes = [2, 3, 5, 7, 11, 13, 17]
        for i in range(1, 8):
            if int_from_digits(pandigit_list[i:i + 3]) % div_primes[i - 1] != 0:
                return False
    return True
Пример #4
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)
Пример #5
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)))