I'm trying to do the Tower of Hanoi but I don't know how to add a count incrementer. Here's my code:
open System
let disks = Int32.Parse(Console.ReadLine())
let rec hanoi num start finish =
match num with
| 0 -> [ ]
| _ -> let temp = (6 - start - finish)
(hanoi (num-1) start temp) @ [ start, finish ] @ (hanoi (num-1) temp finish)
[<EntryPoint>]
let main args =
(hanoi disks 1 2) |> List.iter (fun pair -> match pair with
| a, b -> printf ": %A %A\n" a b)
0
I'm trying to get it to print out something like this
1: 1 3
2: 1 2
3: 3 2
etc...
I'm aware that there is no formatting set for the
1:
2:
3:
part. I know that the proper formatting is
"%A: %A %A\n" *with some counter here* a b
however I don't know how to do this. I've looked for an answer on the web but I have not found anything. If anyone could please help me, that would be greatly appreciated.
Thank you in advance