import random as r
def hanoi(nb_disks,start, middle, end):
    l=[]
    hanoi_rec(l,nb_disks,start, middle, end)
    return l

def hanoiVerif(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)

def testhanoi(x):
    if(hanoi(3,"A","B","C")!=[['A','C'],['A','B'],['C','B'],['A','C'],['B','A'],['B','C'],['A','C']]):
        return False
    for i in range(x):
        j=r.randint(1,4)
        if(hanoi(j,"Z","E","R")!=hanoiVerif(j,"Z","E","R")):
           return False
    return True

print(testhanoi(5))


