Skip to content

Instantly share code, notes, and snippets.

@ntddk
Last active March 2, 2016 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntddk/87cf69f90faf7b382ef5 to your computer and use it in GitHub Desktop.
Save ntddk/87cf69f90faf7b382ef5 to your computer and use it in GitHub Desktop.
寿司 虚空編 002
def f(x):
return x + 1
def b(m, n):
if m == 0 and n > 0:
return f(n)
elif m > 0 and n == 0:
return b(m - 1, 1)
else:
return b(m - 1, b(m, n - 1))
def g(x):
return b(x, x)
def main():
print g(3)
if __name__ == "__main__":
main()
@ntddk
Copy link
Author

ntddk commented Mar 2, 2016

# python -m cProfile -s time .\sushi.py
61
         3626 function calls (1195 primitive calls) in 0.001 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   2432/1    0.001    0.000    0.001    0.001 sushi.py:4(b)
        1    0.000    0.000    0.001    0.001 {execfile}
        1    0.000    0.000    0.001    0.001 sushi.py:15(main)
     1188    0.000    0.000    0.000    0.000 sushi.py:1(f)
        1    0.000    0.000    0.001    0.001 <string>:1(<module>)
        1    0.000    0.000    0.001    0.001 sushi.py:1(<module>)
        1    0.000    0.000    0.001    0.001 sushi.py:12(g)
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment