hanoi.py
1 |
|
---|---|
2 |
def hanoi(n, tour_depart, tour_arrivee, tour_intermedaire): |
3 |
if n <= 0: |
4 |
return
|
5 |
hanoi(n - 1, tour_depart, tour_intermedaire, tour_arrivee)
|
6 |
tour_arrivee.append(tour_depart.pop()) |
7 |
hanoi(n - 1, tour_intermedaire, tour_arrivee, tour_depart)
|
8 |
|
9 |
|
10 |
A = list(range(5)) |
11 |
B = list()
|
12 |
C = list()
|
13 |
|
14 |
print(A, B, C) |
15 |
hanoi(len(A), A, C, B)
|
16 |
print(A, B, C) |