<commit_before>__author__ = 'shawnmehan'

"""Class to calculte the triangle numbers and then determine how many divisors they have.
Objective is to find first triangle number with > 500 divisors"""


def get_divisors(n):
    divisors = []
    if n % 2 != 0:
        divisors.append(2)
        divisors.append(n % 2)
    if n % 3 != 0:
        divisors.append(3)
        divisors.append(n % 3)
    for d in range(4, n/4):
        if n % d == 0:
            divisors.append(d)
    divisors.append(n)
    return sorted(divisors)


def get_divisors2(n):
    divisors = []
    for d in range(1, n):
        """If d is in the list, we have crossed the half-way point and can stop"""
        if d in divisors:
            break
        """Otherwise, test to see if a divisor, and then add both to set"""
        if n % d == 0:
            r = n / d
            divisors.append(d)
            divisors.append(r)
    return sorted(divisors)


tri_sum = 0
tri_sum_divs = 0
for i in range(6000):
    tri_sum += i+1
    tri_sum_divs = get_divisors2(tri_sum)
    if len(tri_sum_divs) > 300:
        print "Close: %dth triangle number, %d, has length: %d" % (i, tri_sum, len(tri_sum_divs))
    if len(tri_sum_divs) > 500:
        print i
        break

print tri_sum, len(tri_sum_divs), tri_sum_divs

<commit_msg>Took it down by finding the halfway point of the divisor space while moving through it. Pretty slow still but achieved a solution.<commit_after>__author__ = 'shawnmehan'

"""Class to calculte the triangle numbers and then determine how many divisors they have.
Objective is to find first triangle number with > 500 divisors"""


def get_divisors(n):
    divisors = []
    if n % 2 != 0:
        divisors.append(2)
        divisors.append(n % 2)
    if n % 3 != 0:
        divisors.append(3)
        divisors.append(n % 3)
    for d in range(4, n/4):
        if n % d == 0:
            divisors.append(d)
    divisors.append(n)
    return sorted(divisors)


def get_divisors2(n):
    divisors = []
    for d in range(1, n):
        """If d is in the list, we have crossed the half-way point and can stop"""
        if d in divisors:
            break
        """Otherwise, test to see if a divisor, and then add both to set"""
        if n % d == 0:
            r = n / d
            divisors.append(d)
            divisors.append(r)
    return sorted(divisors)


tri_sum = 0
tri_sum_divs = []
n = 1
while len(tri_sum_divs) <= 500:
    tri_sum += n
    tri_sum_divs = get_divisors2(tri_sum)
    if len(tri_sum_divs) > 300:
        print "Close: %dth triangle number, sum %d, has %d divisors" % (n, tri_sum, len(tri_sum_divs))
    n += 1
print "Exited at %dth triangle number, sum %d, with %d divisors" % (n-1, tri_sum, len(tri_sum_divs))
print tri_sum_divs



{'fraction_non_alphanumeric': 0.10591222343126587, 'fraction_numerical': 0.02140007254261879, 'mean_word_length': 2.35931790499391, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '3040532', 'n_tokens_mistral': 1004, 'n_tokens_neox': 968, 'n_words': 321}