Hanoi tower, a subclass of built-in type list
| 22 | self.st() |
| 23 | |
| 24 | class Tower(list): |
| 25 | "Hanoi tower, a subclass of built-in type list" |
| 26 | def __init__(self, x): |
| 27 | "create an empty tower. x is x-position of peg" |
| 28 | self.x = x |
| 29 | def push(self, d): |
| 30 | d.setx(self.x) |
| 31 | d.sety(-150+34*len(self)) |
| 32 | self.append(d) |
| 33 | def pop(self): |
| 34 | d = list.pop(self) |
| 35 | d.sety(150) |
| 36 | return d |
| 37 | |
| 38 | def hanoi(n, from_, with_, to_): |
| 39 | if n > 0: |
no outgoing calls
no test coverage detected
searching dependent graphs…