# coding: utf8
"""
Tower of Hanoi Puzzle
author: ◆6WD5LB4sFVj5
date: 2011/01/12
"""
def hanoi(src, dest, work, discs):
if discs == 0: raise StopIteration()
for x in hanoi(src, work, dest, discs-1): yield x
yield (discs, src, dest)
for x in hanoi(src, work, dest, discs-1): yield x
for (disc,src,dest) in hanoi('A', 'B', 'C', 4):
print 'move %d from %s to %s' % (disc, src, dest)