Last active
September 22, 2020 08:13
-
-
Save vlad-bezden/f5be3862b51935334f83 to your computer and use it in GitHub Desktop.
Solution of Tower of Hanoi problem using F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec TowerOfHanoi fromPole destPole tempPole disks = | |
if disks > 0 then | |
TowerOfHanoi fromPole tempPole destPole (disks - 1) | |
printfn "Moving from %c to %c" fromPole destPole | |
TowerOfHanoi tempPole destPole fromPole (disks - 1) | |
TowerOfHanoi '1' '2' '3' '4' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great write-up! Solution is a lot more readable than some of the other F# solutions out there.
A small correction:
printf
in line 4 should beprintfn
.