Tell us what’s happening:
everything looks good, and i also tried on vscode, got a good return. but i cannot pass the test. there is a issue with 2,3,4,5
Your code so far
def hanoi_solver(number):
first_rod=[i for i in range(number,0,-1)]
third_rod=[]
second_rod=[]
result = f'{first_rod} {second_rod} {third_rod}\n'
def move(n,source,auxiliary,target):
nonlocal result
if n==1:
a=source.pop()
target.append(a)
result += f'{first_rod} {second_rod} {third_rod}\n'
return
move(n-1,source,target,auxiliary)
a=source.pop()
target.append(a)
result += f'{first_rod} {second_rod} {third_rod}\n'
move(n-1,auxiliary,source,target)
move(number,first_rod,second_rod,third_rod)
return repr(result)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Challenge Information:
Implement the Tower of Hanoi Algorithm - Implement the Tower of Hanoi Algorithm