Your question is Tower of Hanoi Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Coupa workflow configuration may need to explain a sequence of dependent operations. Implement the Tower of Hanoi algorithm to generate the optimal sequence of disk moves for such a dependency chain.
You are given n disks arranged from largest at the bottom to smallest at the top on a source peg. Move all disks to a target peg using an auxiliary peg.
A move transfers exactly one top disk from one peg to another. A larger disk may never be placed on a smaller disk. Return the complete sequence of moves in execution order.
Implement solve_hanoi(n, source, auxiliary, target). n is a non-negative integer, and each peg name is a string. Return a list of tuples, where each tuple has the form (from_peg, to_peg). The sequence must use the minimum possible number of moves, 2^n - 1 for n > 0.
The function must not mutate any caller-provided object and must handle n = 0 by returning an empty list.
def solve_hanoi(n, source, auxiliary, target):