[ create a new paste ] login | about

Link: http://codepad.org/EHQn8rW2    [ raw code | output | fork ]

Python, pasted on May 19:
import sys

class memoize:
  def __init__(self, function):
    self.function = function
    self.memoized = {}

  def __call__(self, *args):
    try:
      return self.memoized[args]
    except KeyError:
      self.memoized[args] = self.function(*args)
      return self.memoized[args]

@memoize
def count(x, y):
    if x == 1 or y == 1:
        return 1

    result = count(x - 1, y)
    result += count(x, y - 1)
    return result



print count(35, 67)


Output:
1
580717429720889409486981450


Create a new paste based on this one


Comments: