/gray_towers

Towers of Hanoi/Bucharest, the Gray way

Primary LanguagePythonMIT LicenseMIT

gray_towers

Towers of Hanoi/Bucharest, the "Gray code way".

Example usage:

from gray_hanoi import GrayHanoi


def main():

    gray_hanoi = GrayHanoi(n_disks=3)
    gray_hanoi.solve(verbose=True)

Result:

   000       |        |
  00000      |        |
 0000000     |        |
===========================

    |        |        |
  00000      |        |
 0000000     |       000
===========================

    |        |        |
    |        |        |
 0000000   00000     000
===========================

    |        |        |
    |       000       |
 0000000   00000      |
===========================

    |        |        |
    |       000       |
    |      00000   0000000
===========================

    |        |        |
    |        |        |
   000     00000   0000000
===========================

    |        |        |
    |        |      00000
   000       |     0000000
===========================

    |        |       000
    |        |      00000
    |        |     0000000
===========================

For the Tower(s) of Bucharest:

from gray_bucharest import GrayBucharest


def main():

    gray_bucharest = GrayBucharest()
    configurations = gray_bucharest.solve(verbose=True)
   000       |        |
  00000      |        |
 0000000     |        |
===========================

    |        |        |
  00000      |        |
 0000000    000       |
===========================

    |        |        |    
  00000      |        |
 0000000     |       000
===========================

    |        |        |
    |        |        |
 0000000   00000     000
===========================

    |        |        |
    |       000       |
 0000000   00000      |
===========================

    |        |        |
   000       |        |
 0000000   00000      |
===========================

    |        |        |
   000       |        |
 0000000     |      00000
===========================

    |        |        |
    |        |        |
 0000000    000     00000
===========================

    |        |        |
    |        |       000
 0000000     |      00000
===========================

    |        |        |
    |        |       000
    |     0000000   00000
===========================

    |        |        |
    |       000       |
    |     0000000   00000
===========================

    |        |        |
    |        |        |
   000    0000000   00000
===========================

    |        |        |
    |      00000      |
   000    0000000     |
===========================

    |       000       |
    |      00000      |
    |     0000000     |
===========================

    |        |        |
    |      00000      |
    |     0000000    000
===========================

    |        |        |
    |        |        |
  00000   0000000    000
===========================

    |        |        |
    |       000       |
  00000   0000000     |
===========================

    |        |        |
   000       |        |
  00000   0000000     |
===========================

    |        |        |
   000       |        |
  00000      |     0000000
===========================

    |        |        |
    |        |        |
  00000     000    0000000
===========================

    |        |        |
    |        |       000
  00000      |     0000000
===========================

    |        |        |
    |        |       000
    |      00000   0000000
===========================

    |        |        |
    |       000       |
    |      00000   0000000
===========================

    |        |        |
    |        |        |
   000     00000   0000000
===========================

    |        |        |
    |        |      00000
   000       |     0000000
===========================

    |        |        |
    |        |      00000
    |       000    0000000 
===========================

    |        |       000
    |        |      00000
    |        |     0000000
===========================

References