Skip to content

Instantly share code, notes, and snippets.

@carl-mastrangelo
Created September 26, 2026 19:26
Show Gist options
  • Select an option

  • Save carl-mastrangelo/da9636f5b90028d395613df01d97dd00 to your computer and use it in GitHub Desktop.

Select an option

Save carl-mastrangelo/da9636f5b90028d395613df01d97dd00 to your computer and use it in GitHub Desktop.
def f(a, b, c, d):
print(a, b, c, d)
if a == 0:
return b + c
elif a == 1:
if c == 0:
return 0
else:
return f(0, f(1, b, c - 1, d + 1), b, d + 1)
elif a == 2:
if c == 0:
return 1
else:
return f(1, f(0, c - 1, 1, d + 1), f(2, b, c - 1, d + 1), d + 1)
if __name__ == "__main__":
print(f(2, 7, 7, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment