Debian Codegraph @

tests/inputs/hanoi.inc

raw
1 // https://github.com/compuphase/pawn/tree/main/examples/hanoi.p
2
3 /* The Towers of Hanoi, a game solved through recursion */
4
5 @start()
6 {
7 print "How many disks: "
8 var disks = getvalue()
9 move 1, 3, 2, disks
10 }
11
12 move(from, to, spare, numdisks)
13 {
14 if (numdisks > 1)
15 move from, spare, to, numdisks-1
16 printf "Move disk from pillar %d to pillar %d\n", from, to
17 if (numdisks > 1)
18 move spare, to, from, numdisks-1
19 }