<commit_before>#!/usr/bin/python
#solution: 76576500 

import math

def sprimep(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n < 10:
        values = {
            2: True,
            3: True,
            4: False,
            5: True,
            6: False,
            7: True,
            8: False,
            9: False
        }
        return values.get(n)

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

def primep(n):
    if n < 99:
        return sprimep(n)

    lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    for prime in lowprimes:
        if n % prime == 0:
            return False
    
    i = 99
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

def primes():
    p = 2
    while 1:
        if primep(p):
            yield p
        if p == 2:
            p = 3
        else:
            p += 2

def ndivisors(n, plist):
    piter = plist.__iter__()
    p = piter.next()
    divisors = 1
    while n != 1:
        curcount = 0
        while n % p == 0:
            n /= p
            curcount += 1
        if curcount > 0:
            divisors *= curcount + 1
        p = piter.next()
    return divisors

def euler_problem_12():
    i = 0
    plist = []
    pgen = primes()
    while i < 2000:
        plist.append(pgen.next())
        i += 1
    
print euler_problem_12()<commit_msg>Fixed broken problem 12<commit_after>#!/usr/bin/python
#solution: 76576500 

import math

def sprimep(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n < 10:
        values = {
            2: True,
            3: True,
            4: False,
            5: True,
            6: False,
            7: True,
            8: False,
            9: False
        }
        return values.get(n)

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

def primep(n):
    if n < 99:
        return sprimep(n)

    lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    for prime in lowprimes:
        if n % prime == 0:
            return False
    
    i = 99
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

def primes():
    p = 2
    while 1:
        if primep(p):
            yield p
        if p == 2:
            p = 3
        else:
            p += 2

def ndivisors(n, plist):
    piter = plist.__iter__()
    p = piter.next()
    divisors = 1
    while n != 1:
        curcount = 0
        while n % p == 0:
            n /= p
            curcount += 1
        if curcount > 0:
            divisors *= curcount + 1
        p = piter.next()
    return divisors

def euler_problem_12():
    i = 0
    plist = []
    pgen = primes()
    while i < 2000:
        plist.append(pgen.next())
        i += 1
    
    i = 1
    while 1:
        if 500 < ndivisors((i * (i + 1)) / 2, plist):
            return (i * (i + 1)) / 2
        i += 1
    
print euler_problem_12()
{'fraction_non_alphanumeric': 0.11930379746835443, 'fraction_numerical': 0.06582278481012659, 'mean_word_length': 1.198191933240612, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 5, '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': '4641637', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1102, 'n_words': 326}