<commit_before>#!/usr/bin/env python
#-*-coding:utf-8-*-

'''
It is possible to write five as a sum in exactly six different ways:

4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1

How many different ways can one hundred be written as a sum of at least two positive integers?
'''

import timeit


def memoize(f):
    cache = {}
    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper


#@memoize
def p(k, n):
    if k > n:
        return 0
    elif k == n:
        return 1
    return p(k+1, n)+p(k, n-k)


def calc(n):
    return sum([p(k, n-k) for k in range(1, int(n/2)+1)])<commit_msg>generalize function and enabled @memoize<commit_after>#!/usr/bin/env python
#-*-coding:utf-8-*-

'''
It is possible to write five as a sum in exactly six different ways:

4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1

How many different ways can one hundred be written as a sum of at least two positive integers?
'''

import timeit


def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper


@memoize
def p(k, n):
    if k > n:
        return 0
    elif k == n:
        return 1
    return p(k+1, n)+p(k, n-k)


def calc(n):
    return sum([p(k, n-k) for k in range(1, int(n/2)+1)])
{'fraction_non_alphanumeric': 0.14275466284074606, 'fraction_numerical': 0.03730272596843615, 'mean_word_length': 2.2142857142857144, 'pattern_counts': {'":': 0, '<': 3, '<?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': '295063', 'n_tokens_mistral': 572, 'n_tokens_neox': 529, 'n_words': 208}