The Tower of Hanoi is a mathematical puzzle where we have three rods and N disks of different sizes. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top. The objective is to move the entire stack to another rod, obeying simple rules.
{
"N": 2,
"from": "A",
"to": "C",
"aux": "B"
}[
"move disk 1 from rod A to rod B",
"move disk 2 from rod A to rod C",
"move disk 1 from rod B to rod C"
]{
"N": 3,
"from": "A",
"to": "C",
"aux": "B"
}[
"move disk 1 from rod A to rod C",
"move disk 2 from rod A to rod B",
"move disk 1 from rod C to rod B",
"move disk 3 from rod A to rod C",
"move disk 1 from rod B to rod A",
"move disk 2 from rod B to rod C",
"move disk 1 from rod A to rod C"
]{
"N": 1,
"from": "A",
"to": "B",
"aux": "C"
}[
"move disk 1 from rod A to rod B"
]Sign in to Run Code and Submit