Created
December 7, 2018 14:25
-
-
Save zwfang/a3e13761573ccb72b8bef6b6d51fbeca to your computer and use it in GitHub Desktop.
hanio
This file contains 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
#!/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