Skip to content

Instantly share code, notes, and snippets.

@zwfang
Created December 7, 2018 14:25
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 zwfang/a3e13761573ccb72b8bef6b6d51fbeca to your computer and use it in GitHub Desktop.
Save zwfang/a3e13761573ccb72b8bef6b6d51fbeca to your computer and use it in GitHub Desktop.
hanio
#!/usr/bin/env python3
import sys
def move(n, x, y, z):
if n == 1:
print("%s --> %s" % (x, z))
else:
move(n-1, x, z, y)
print("%s --> %s" % (x, z))
move(n-1, y, x, z)
if __name__ == "__main__":
move(int(sys.argv[1]), sys.argv[2], sys.argv[3], sys.argv[4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment