v / examples
Raw file
		
1// hanoi tower
2const (
3 num = 7
4)
5
6fn main() {
7 hanoi(num, 'A', 'B', 'C')
8}
9
10fn move(n int, a string, b string) {
11 println('Disc $n from $a to ${b}...')
12}
13
14fn hanoi(n int, a string, b string, c string) {
15 if n == 1 {
16 move(1, a, c)
17 } else {
18 hanoi(n - 1, a, c, b)
19 move(n, a, c)
20 hanoi(n - 1, b, a, c)
21 }
22}