Skip to content

Instantly share code, notes, and snippets.

@ikautak
Created April 12, 2013 15:09
Show Gist options
  • Save ikautak/5372723 to your computer and use it in GitHub Desktop.
Save ikautak/5372723 to your computer and use it in GitHub Desktop.
Python implementation of Tak.
#!/usr/bin/env python
def tarai(x, y, z):
if x <= y:
return y
else:
return tarai(
tarai(x-1, y, z),
tarai(y-1, z, x),
tarai(z-1, x, y))
x = 12
y = 6
z = 0
print(tarai(x, y, z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment