SHARE
TWEET

Untitled

a guest Nov 12th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int start = aux[0];
  2.     int goal = aux[1];
  3.        
  4.     if (n_dsks == 1)
  5.         moves.push_back(VI { aux[0], aux[1] });
  6.  
  7.     else {
  8.         int k = k_hanoi[n_twrs][n_dsks];
  9.        
  10.         // moves top k disks from start to sparing tower
  11.         int sparing = aux[n_twrs-1];
  12.         aux[1] = sparing;
  13.         aux[n_twrs-1] = goal;
  14.         hanoi(moves, n_twrs, k, aux);
  15.        
  16.         // moves bottom n-k disks from start to goal
  17.         aux[0] = start;
  18.         aux[1] = goal;
  19.         hanoi(moves, n_twrs - 1, n_dsks - k, aux);
  20.        
  21.         // moves original k disks from sparing tower to goal
  22.         aux[0] = sparing;
  23.         aux[n_twrs-1] = start;
  24.         hanoi(moves, n_twrs, k, aux);
  25.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top