<commit_before>#! /usr/bin/python
from __future__ import print_function
from math import sqrt
from time import time
from itertools import permutations


# Project Euler # 40


# def is_pandigital(n):
#     length = len(str(n))
#     if length > 9:
#         return False
#     digits = map(int, set(n))
#     if len(digits) != length or 0 in digits:
#         return False
#     for digit in digits:
#         if digit > length:
#             return False
#     return True


def is_prime(n):
    """ return True if n is a prime number"""
    if n < 2:
        return False
    if n == 2 | n == 3:
        return True
    if n % 2 == 0 | n % 3 == 0:
        return False
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0:
            return False
    return True


if __name__ == '__main__':
    # start at greatest
    digits = '987654321'
    digits_list = []
    for i in range(len(digits)):
        digits_list.append(digits)
        digits = digits[1:]
    start = time()
    end = False
    for i in digits_list:
        for p in permutations(i):
            current = int("".join(p))
            # only checks odd values for performance
            if current % 2 == 1:
                # print(current)
                if is_prime(int("".join(p))):
                    print("greatest pandigital prime is", 
                          current,
                          "in time:", time() - start)
                    end = True
                    break
        if end is True:
            break<commit_msg>41 solved in .001 seconds now<commit_after>#! /usr/bin/python
from __future__ import print_function
from math import sqrt
from time import time
from itertools import permutations


# Project Euler # 40


# def is_pandigital(n):
#     length = len(str(n))
#     if length > 9:
#         return False
#     digits = map(int, set(n))
#     if len(digits) != length or 0 in digits:
#         return False
#     for digit in digits:
#         if digit > length:
#             return False
#     return True


def is_prime(n):
    """ return True if n is a prime number"""
    if n < 2:
        return False
    if n == 2 | n == 3:
        return True
    if n % 2 == 0 | n % 3 == 0:
        return False
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0:
            return False
    return True


if __name__ == '__main__':
    # start at greatest
    # 1+2+3+4+5+6+7+8+9=45 => divisable by 3)
    # 1+2+3+4+5+6+7+8=36 => divisable by 3)
    digits = '7654321'
    digits_list = []
    for i in range(len(digits)):
        digits_list.append(digits)
        digits = digits[1:]
    start = time()
    end = False
    for i in digits_list:
        for p in permutations(i):
            current = int("".join(p))
            # only checks odd values for performance
            if current % 2 == 1:
                # print(current)
                if is_prime(int("".join(p))):
                    print("greatest pandigital prime is", 
                          current,
                          "in time:", time() - start)
                    end = True
                    break
        if end is True:
            break
{'fraction_non_alphanumeric': 0.10716550412175016, 'fraction_numerical': 0.024730500951173115, 'mean_word_length': 1.5839475839475838, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1719740', 'n_tokens_mistral': 1038, 'n_tokens_neox': 948, 'n_words': 326}