Created
May 17, 2011 01:42
-
-
Save teepark/975734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
import traceback | |
def minus1(x): | |
return x - 1 | |
def plus1(x): | |
return x + 1 | |
def add_pos(x, y): | |
maxdepth = sys.getrecursionlimit() - len(traceback.format_stack()) | |
chunksize = int(math.ceil(float(x) / maxdepth)) | |
def recursion(x, y): | |
for i in xrange(chunksize): | |
if not y: | |
return x | |
x, y = plus1(x), minus1(y) | |
return recursion(x, y) | |
return recursion(x, y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment