title: Would this algorithm be considered a minimal-change algorithm?
body: <p>For my algorithms class we are required to write a bottoms-up minimal-change algorithm.</p>
  
  <p>As an example output our professor provided us with</p>
  
  <pre><code>n=4
  1234     2314     3124
  1243     2341     3142
  1423     2431     3412
  4123     4231     4312
  4132     4213     4321
  1432     2413     3421
  1342     2143     3241
  1324     2134     3214
  </code></pre>
  
  <p>Notice that it generates 24 permutations (6 for each digit). The permutations for 4 (as in, 4 being the first number in a permutation) are a byproduct from the other calls in that algorithm. You can also see that at most only 2 numbers every switch positions.</p>
  
  <p>I've been struggling to find a good pattern within those numbers to base my code on.
  So I was thinking of taking a slightly different approach to the problem.</p>
  
  <p>If I take the factorial of <code>n</code> I can calculate the number of permutations. By dividing the number of permutations by <code>n</code> I get the number of times each digit is in each respective position (i.e. how many permutations start with each number). Dividing the subsequent result by n-1 I get the number of times each second digit will occur, given the first digit remains the same. So on and so forth (with n being decreased by one every time) until all digits have been exhausted.</p>
  
  <p>As an example, assume that <code>n=4</code></p>
  
  <pre><code>4! = 24
  24/4 = 6
  6/3 = 2
  2/2 = 1
  </code></pre>
  
  <p>Using these results I can generate permutations vertically, not horizontally.</p>
  
  <p>Instead taking a number and sliding it back and forth over the other numbers and doing swaps every so often I would instead generate a table that is <code>nxn!</code> in dimension. Then, going down the columns fill in the first column with 6 ones, 6 twos, 6 threes, 6 fours, and 6 fives.</p>
  
  <p>When I get to second column each number would be put in twp times, and then repeated until the end of the array is reached. Subsequently, each column would follow a similar pattern. This pattern would work with any sized <code>n</code> input.</p>
  
  <p>My output would be this:</p>
  
  <pre><code>n=4
  1234    2134    3124    4123
  1243    2143    3142    4132
  1324    2314    3214    4213
  1342    2341    3241    4231
  1423    2413    3421    4312
  1432    2431    3412    4321
  </code></pre>
  
  <p>Now my question is... is this still considered a minimal-change algorithm?</p>
  
  <p>My algorithm works more in lexicographical order, and that worries me that it may not be considered a minimal-change algorithm (because during certain steps more than one number seems 'swapped', though in reality no swapping is being done).</p>