IbrahimHassan

Tower Of Hanoi Swift

Jul 26th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. func TOH(n : Int, a: Int, b : Int, c : Int)
  2. {
  3. if (n > 0) {
  4. TOH(n: n-1, a: a, b: c, c: b)
  5. print ("Move a Disc from \(a) to \(c)")
  6. TOH(n: n-1, a: b, b: a, c: c)
  7. }
  8. }
  9.  
  10. TOH(n: 1, a: 1, b: 2, c: 3)
Add Comment
Please, Sign In to add comment