Back to Templates
This is an example of using sub-workflow nodes and a proof of concept showing that it’s possible to solve and explain recursive problems with n8n.
Move a stack of n disks from rod A to rod C, using rod B as auxiliary. Only one disk can be moved at a time, and no disk may be placed on a smaller disk.
n=4
| | |
= | |
=== | |
===== | |
======= | |
--------- --------- ---------
A B C
procedure Hanoi(n, X, Y, Z):
if n == 1:
move disk from X to Z
else:
Hanoi(n-1, X, Z, Y)
move disk from X to Z
Hanoi(n-1, Y, X, Z)