How to resolve the algorithm Towers of Hanoi step by step in the REBOL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Towers of Hanoi step by step in the REBOL programming language
Table of Contents
Problem Statement
Solve the Towers of Hanoi problem with recursion.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Towers of Hanoi step by step in the REBOL programming language
Source code in the rebol programming language
REBOL [
Title: "Towers of Hanoi"
URL: http://rosettacode.org/wiki/Towers_of_Hanoi
]
hanoi: func [
{Begin moving the golden disks from one pole to the next.
Note: when last disk moved, the world will end.}
disks [integer!] "Number of discs on starting pole."
/poles "Name poles."
from to via
][
if disks = 0 [return]
if not poles [from: 'left to: 'middle via: 'right]
hanoi/poles disks - 1 from via to
print [from "->" to]
hanoi/poles disks - 1 via to from
]
hanoi 4
You may also check:How to resolve the algorithm Church numerals step by step in the Go programming language
You may also check:How to resolve the algorithm Lucas-Lehmer test step by step in the Swift programming language
You may also check:How to resolve the algorithm Magic squares of odd order step by step in the REXX programming language
You may also check:How to resolve the algorithm Tokenize a string step by step in the Nial programming language
You may also check:How to resolve the algorithm Combinations and permutations step by step in the PARI/GP programming language