Created
January 7, 2017 02:27
-
-
Save yunho0130/aa44ab827e1a7b6b9eeb8d4e027911f9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Sun Jan 01 17:46:04 2017 | |
| @author: Yunho | |
| """ | |
| def hanoi(num_disks, start_peg, temp_peg ,end_peg): | |
| if num_disks == 1: | |
| print '{} -> {}'.format(start_peg, end_peg) | |
| else: | |
| hanoi(num_disks-1, start_peg, end_peg, temp_peg) # 섞기 | |
| hanoi(1, start_peg, temp_peg, end_peg) # 출력라인 | |
| hanoi(num_disks-1, temp_peg, start_peg, end_peg) # 섞기 | |
| def main(): | |
| hanoi(3, 'A', 'B', 'C') | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment