You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
400 B
16 lines
400 B
def hanoi(nb_disks,start, middle, end):
|
|
l=[]
|
|
hanoi_rec(l,nb_disks,start, middle, end)
|
|
return l
|
|
|
|
def hanoi_rec(l,nb_disks, start, middle, end):
|
|
if nb_disks == 1:
|
|
return l.append([start,end])
|
|
else:
|
|
hanoi_rec(l,nb_disks - 1, start, end, middle)
|
|
l.append([start,end])
|
|
hanoi_rec(l,nb_disks - 1, middle, start, end)
|
|
|
|
print(hanoi(4,"A","B","C"))
|
|
|