Generation

generate functionTue, 15 Nov 2022

Hanoi

fun hanoi(n: Int, s: String, d: String, e: String) { if (n == 1) println("Move 1 from $s to $d") else { hanoi(n - 1, s, e, d) println("Move $n from $s to $d") hanoi(n - 1, e, d, s) } }

Questions about programming?Chat with your personal AI assistant