Towers of Hanoi for Python

Author https://travis-ci.org/sys-git/towers.svg?branch=master https://coveralls.io/repos/github/sys-git/towers/badge.svg Documentation Status https://badge.fury.io/py/towers.svg https://img.shields.io/pypi/l/towers.svg https://img.shields.io/pypi/wheel/towers.svg https://img.shields.io/pypi/pyversions/towers.svg https://img.shields.io/pypi/status/towers.svg Updates Python 3

The `Towers of Hanoi` algorithm.

Example

>>> tower = Towers(height=3)
>>> print(tower)
Towers(Rods(3 - start([***, **, *]), end([]), tmp([])))

>>> print('moves required: {moves}'.format(moves=tower.moves_for_height(height)))
moves required: 7

>>> with tower:
...    for i in tower:
...        print(i)
Move(disk=*, start=Rod(name='start', disks=[***, **, *], height=3), end=Rod(name='end', disks=[], height=3), moves=0)
Move(disk=**, start=Rod(name='start', disks=[***, **], height=3), end=Rod(name='tmp', disks=[], height=3), moves=1)
Move(disk=*, start=Rod(name='end', disks=[*], height=3), end=Rod(name='tmp', disks=[**], height=3), moves=2)
Move(disk=***, start=Rod(name='start', disks=[***], height=3), end=Rod(name='end', disks=[], height=3), moves=3)
Move(disk=*, start=Rod(name='tmp', disks=[**, *], height=3), end=Rod(name='start', disks=[], height=3), moves=4)
Move(disk=**, start=Rod(name='tmp', disks=[**], height=3), end=Rod(name='end', disks=[***], height=3), moves=5)
Move(disk=*, start=Rod(name='start', disks=[*], height=3), end=Rod(name='end', disks=[***, **], height=3), moves=6)

>>> print(tower)
Towers(Rods(3 - start([]), end([***, **, *]), tmp([])))

>>> print('moves taken: {moves}'.format(moves=tower.moves))
moves taken: 7

Installation

Instructions can be found here

Contributions

Guidelines can be found here

Authors can be found here

Indices and tables